you are here: Home Home TDD

Constant focus on quality and code health is critical for the long term viability and maintainability of software.  This focus on quality is a trademark of agile teams but you don't have to be 'doing the Agile' to focus on quality. Regardless of how you develop software, testing and in particular unit testing are an important tool to have in your toolbox.  Given the importance of unit level testing, why do so many companies struggle with unit testing and its adoption? When unit level testing is non-existent or inconsistent, the reasons fall into two main categories:

  • General misunderstanding on what a unit test provides
  • Developers aren't good / shy away from testing as it is out of their comfort zone

There is a third reason, more like a myth, that is very popular - the myth that 'we don't have time to test'.  This is false - nothing will slow you down more than writing as much code as you can without some way of constantly being able to verify you haven't broken your assumptions of the intent of the code.  We tend to hear this myth coming mostly from developers.  This comment is usually rooted in a blend of the two primary reasons with the majority of the cause coming from developers simply shying away from testing.

Del.icio.us!StumbleUpon!

Agile practices may seem easier for small, isolated teams but what happens in the real world when applications go across teams and dependencies rear their ugly head?  The answer I hear too often is 'adjust in your planning sessions so that the dependencies go away.'  That's not a real, complete solution to me.  Here is why - that answer makes sense if we are creating an application and we have two stories - Add item to shopping cart and Remove item from shopping cart for example.  In this case its logical to plan accordingly.  We wouldn't want to release the product without being able to add items and additionally this functionality seems in control by the team.

What about this more common example though - a front end team develops an application that depends on data from a data team.  On top of that, not only does the front end team depend on the data team, but so do 3 other teams, all with different priorities and needs.  And since it is the real world, we have a deadline to hit - the application needs to launch in 6 weeks and the data team won't be able to finalize the data for the front end team for 4 weeks.  It doesn't make sense for the front end team to not work, especially if the amount of time they need is greater than the remaining two weeks.  What do you do?

Del.icio.us!StumbleUpon!

You are a responsible developer, practicing TDD and keeping your code clean through refactoring.  Your 'bar' is always green, but are you living and developing in a world of 'False Green'?  Is your green bar continuous or is it only measured at points in time - when you run your tests for example.  At the Lean Conference in April, Joshua Kerievsky gave an excellent presentation titled 'The Limited Red Society.' A summary of this presentation can be found on Joshua's site here and the video can be found here. Synopsis: we need to be aware of the state of our code at all times, not just when we run our tests.  In the real world, things may break at non-ideal times, like during the middle of a refactoring, and we must fix them. Joshua's session really hit home about a month ago when I felt like I was refactoring with fire.


To set the stage, I was working solo on some custom code for a customer.  I developed it test-driven and had solid tests.  After I delivered the code to the customer, I saw a great spot for refactoring and simplifying the code so I dove in.  Then the customer came back with a change...but I was in the middle of refactoring! The change would only take me about 10 minutes but the refactoring session would last another hour or two to get to the point where I wanted it.  Right then I felt like I was refactoring with fire.  This was only a 10 minute change but a production emergency could go on quite a bit longer and I would be leaving my codebase unstable. I vowed to not let that happen again.

Del.icio.us!StumbleUpon!

Who's Online

We have 30 guests online

Advertisement

Featured Links:
Joomla!
Joomla! The most popular and widely used Open Source CMS Project in the world.
JoomlaCode
JoomlaCode, development and distribution made easy.
Joomla! Extensions
Joomla! Components, Modules, Plugins and Languages by the bucket load.
Joomla! Shop
For all your Joomla! merchandise.

Login Form