Feb 01 2009

Software Quality

Category: Software Development,TestingPhil @ 12:00 pm

What makes a high quality piece of software? Kind of a tough question to answer; everyone has their own idea of quality. I like to look at quality from a team perspective; I believe that quality software has the following signature traits:

  • Shared vision, documented design
  • Code that is easy to change and supports refactoring
  • Ability to prove that the code executes correctly
  • Code consistency

None of these traits are original and they all have their roots in traditional software development methodologies. I believe that their relevancy was renewed by the Extreme Programming and Agile development movements and actually made possible by tools which have emerged over the last few years. There are definitely other traits that convey software quality, such as efficiency, usability, and applicability. However, I believe that these are more dependent on individual efforts, rather than a product of team cohesiveness.

I know there are many alternative views and even skeptics who claim we don’t need coding standards or unit test suites. They believe their systems represent high quality software; but how do they really know? What proof do they really have? To their defense, the applications have been running, performing real business function, requiring very little maintenance, and apparently very few bugs. But, do those criteria actually imply quality? The stability of a system is definitely an important quality trait, but I would consider it a secondary trait; one that is actually a side effect of a signature trait, proof that the code actually executes properly.

While writing, I also realized there was another dimension that supersedes all other traits, the team’s cohesiveness. I believe it is very much related to having a ‘vision’, for a team to effectively produce quality software, there needs to be complete synergy. This sounds a lot like ‘assimilation’, maybe it is, but I really don’t like that word. I don’t think I have ever seen a team without a vision, but rather too many incompatible visions; they never have the opportunity to form the unified vision. This encompasses how things are designed, how they are constructed, and even how they are tested. If the team does not have synergy, achieving quality will cost a lot more. This cost will not be a corporate cost, but more of a individual cost, the additional effort required by each member of the team to ensure the project gets finished.

There is another, more personal trait that I like to apply to my projects, the desire to do things better the next time around. I’m not sure about you, but I have never built the perfect piece of software. I always think about how I could have done a better design or a better job coding. We don’t always get the chance to redo our work. But without seriously evaluating our own work, how can we ever learn from our mistakes. It is very important that the team wants to evolve, if the team is wed to their current coding patterns and practices, then achieving higher levels of quality is going to be much harder, maybe even impossible. I think quality is evolutionary; you just don’t “make” quality happen. The team has to be interested and excited about creating the best possible software, within their current environment.

Within their current environment; it is a very interesting qualifier to the above statement. I believe many teams use their environment as an excuse to keep the status quo. I think it is very important and my personal responsibility to do things better, every day, every iteration, every assignment. I have never worked on a project that did not have some amount of built-in cushion, for all of those unplanned requirements. Moreover, if it was something that the team really believed in and wanted to do, then we made it happen; if that meant some long hours, then that is what we did. Teams need to use the slow times to their advantage, adding new tool and techniques to their toolbox, improving the development process, and going after those nagging problems that never get addressed.

I have worked with and observed teams where the software development environment was like a game, developers were challenged and excited to create clean builds, remove warnings, and even create unit test. I have seen teams actually compete to generate better code coverage numbers than a rival team. <Disclaimer>High code coverage does not imply high quality code; more on that later!</Disclaimer>. The bottom line is, these teams wanted to make their code better and doing these activities was considered fun rather than a burden or something that provided no value. To further illustrate my point, I found a plug-in for the Hudson Continuous Integration tool that I would love to try, it is call the “Continuous Integration Game”. Developers actually earn (or lose) points depending on the code they check in. Break the build, lose 10 points, add a unit test and earn a point. It may seem silly, but if inexpensive, little metrics can help energize a team, then I am all for it.

I really don’t think I addressed any of my signature traits in this post, but it was important to establish a philosophical baseline for future posts on quality software development. In future posts, I hope to address how we have used tools and techniques to continuously improve our software development process and ultimately, build better software.

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Nov 23 2008

Unit Testing with Spring 2.5.x

Category: Java,TestingPhil @ 1:08 pm

Sometime back, using the Spring Framework and jUnit 4.x was not very elegant. Spring only supported dependency injection by sub-classing their AbstractDependencyInjectionSpringContextTests class. The coolest thing about jUnit 4.x was the implementation of annotations and the elimination of the requirement to extend the jUnit TestCase class. Obviously, this was considered an issue by many people, as several projects created their own solutions for jUnit 4.x integration. One such implemenation was Unitils, which I used on several projects. I did not take advantage of all of the Unitils features (Mock Objects, JPA, or DBUnit integration), only the dependency injection and a little of the Hibernate and Transaction management support.

Someone recently hipped me to the fact, that somewhere along the way, Spring finally added support for jUnit 4.x. I wanted to see if I could possibly eliminate the need to Unitils.  Only have only played with the integration for short time, but it appears to do what is required. The only real issue I encountered was having to downgrade from jUnit 4.5 to jUnit 4.4.  Unfortunately jUnit 4.5 broke the integration, and will not work. However, moving back to jUnit 4.4 solved all of the issues.

The basic class level annotations that you need to be aware of are @RunWith(SpringJUnit4ClassRunner.class) and @ContextConfiguration(locations = { “/com/sample/resources/applicationContext.xml” }).  I have seen the @RunWith annotation used by many new jUnit extensions, it seems pretty cool. The ContextConfiguration is pretty obvious, you can provide a list of XML files which contain your Spring context

Next you can simple provide the @Autowired or @Resource annotation to your test class properties. Spring will then inject those objects for you at execution time. They did provide the @Qualifier(“alternateBeanName”) annotation which allows you to remove possible ambiguity.

One thing that was not entirely obvious to me was the @TestExecutionListeners annotation. One of the Spring examples had it set to {}, which effectively turns off the dependency injection. It would have best to leave it out! Anyway, there are several other Listeners that you might want to be aware of, such as dealing with Transactions and a dirty spring context.

On of the more interesting annotations, (which was not in Unitils) was the idea of making tests specific to an environment. While this  is probably not that common, I have had situations where I can only run a test in the CI (Continuous Integration) environment, or maybe only I only want it to run on my development box. The @IfProfileValue annotaion provides this ability. The default implementation allows you to do simple “if logic” base on Java properties. It is also possible to define your own configuration (something that determines the value of the requested attributes) class, using the @ProfileValueSourceConfiguration(Include.class). Pretty cool, I can actually see using this feature in the future.

There are plenty of other annotations that will be useful, such as @BeforeTransaction, @AfterTransaction, @Rollback, and @NotTransactional.

I believe that the @RunWith and @ProfileValueSourceConfiguration annotations can be very useful in building a consistency unit test strategy, effectively hiding much of the noise associated with most jUnits (noise = configuration and setup tasks). Personally, I find jUnit 4.x much more elegant that the original (pre 4.x) strategy, providing a much cleaner implementation.

I believe that unit testing is essential to projects, and will continue on my personal mission to push for Test Driven Development. I truly believe that done right, “Testing is basically Free”… especially when you consider the integration environments provided by Spring and development tools such as Eclipse. How can anyone afford NOT to test?  Enough soapbox for the day, here was yet another little TDD article.

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Oct 15 2008

Does your code suck?

Category: TestingPhil @ 8:23 pm

Sounds like something I would say… but not this time!  My company hired Dave Astels to do some consulting work a few years ago… probably after he wrote his TDD book. After meeting him at work one day, I started following his blogs…

I happened to run across this post from 2004 “Why Your Code Sucks, it is kind of old… but I really liked the point it was making….  I also thought the comments were very interesting.

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Aug 25 2008

jUnit 4.x Test Suites…

Category: Java,TestingPhil @ 8:11 pm

Have you ever wanted to run all of your jUnit tests from within Eclipse? It is pretty easy if they are in the same package, but if you have a hierarchy of packages, you are out of luck! I learned quite a few jUnit tricks tonight, even found the exact code I was looking for. You can read about some annotation-based test suites at this site. This guy gave me the exact code I was looking for, maybe someday they will add this feature directly to jUnit!

I’m still digging Unitils as well… I found a cool annotation to rollback the transaction for a specific test case. This is kind of nice when you don’t want your jUnits messing up your database! Check this out…

@Test
@Transactional(TransactionMode.ROLLBACK)
public void validateLoad() {…}

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


Oct 31 2007

Crap4J

Category: Java,TestingPhil @ 7:27 pm

Everyone knows that I’m always preaching about code quality and testing, and yesterday I was reading something on the web that I just thought was just too funny. There is actually an Eclipse plug-in called crap4j. It provides a metric to identify code which is difficult to understand, test, or maintain. CRAP actually stands for Change Risk Analysis and Predictions. Here was an interesting blog on CRAP. I have not had the time to read more about this metric, but I like tools that help provide feedback to developers, in my opinion, these tools only help us write better code, and seldom get in the way. The biggest problem is usually getting the team to buy into them. Hopefully, I will have some time to learn about this metric and actually try the plug-in; but with the name and logo like they selected, how can it be bad?

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png


« Previous Page