Agile Zone is brought to you in partnership with:

Mike is a certified PMP project manager and a certified ScrumMaster. Mike was involved with the creation of the DSDM Agile Project Leader certification, holds this certification at the Foundation, Practitioner, and Examiner levels. Mike was named an honorary member of the DSDM consortium and served on the board of APLN and the Lean Software and Systems Consortium. He currently co-leads the PMI Agile Community of Practice. Mike is a DZone MVB and is not an employee of DZone and has posted 143 posts at DZone. You can read more from them at their website. View Full User Profile

Stop Writing Code You Can’t Yet Test

  • submit to reddit
This post was originally written by Dennis Stevens at LeadingAgile.

Most of the organizations we engage with have more work to do than they can possibly get done. So, developers are writing code as fast as they can to get done trying to maximize their capacity. Typically, we see developers running way ahead of testing. Often, testing is still working on the prior release while development is running off on the next release – and testing just can’t ever catch up. This inventory of untested code shows up as long lists of defects, lots of code branches, untestable features, and products that can’t be integrated or regression tested until just before the next release. This vicious cycle of long bug lists, painful regression testing, and production defects colliding with the next release continues to grow.

The goal is not to write code faster. The goal is to produce valuable, working, testing, remediated code faster. The most expensive thing developers can do is write code that doesn’t produce something needed by anyone (product, learning, etc.). The second most expensive thing developers can do is write code that can’t be tested right away. Recently, LeadingAgile’s Derek Huether wrote about Getting Teams to Deliver Predictably. He shows how having more work in the queue than can be performed slows down throughput. Pretty quickly, everything gets congested and things back up, building up latency and uncertainty in flow.

So, we understand that it is not a good economic investment for developers to write code that can’t be tested. It isn’t getting done faster – and it’s increasing the cost of all the work in process. Even people that understand this push back, however. We hear developers have to be busy – that not writing code is not a good economic option.

There are at least six things that developers can work on that are better economic investments than writing untested code.

  1. Get ready for upcoming work – In complex products, not being able to make and keep commitments creates delays that are very costly. Rather than writing code that can’t be tested in the sprint developers should be figuring what they need to understand for the next (or future) sprint(s). They are going to have to figure it out at some point, anyway. Figuring it out ahead of the sprint improves the ability to make commitments, so it is a better choice than figuring it out in the sprint.
  2. Help finish work in progress – Developers can (and should) pair with testers to find and fix bugs, or pair with developers to finish other work that the team committed in the sprint.
  3. Expand capability and future capacity – There are often scarce skills or knowledge sets that only a few people on a team can do. Rather than writing code that can’t be tested, developers can pair with someone to develop team capability and capacity. Even if the new person isn’t as productive as the old person at this scarce skill or knowledge set, it is still a better economic investment than writing code that can’t be tested.
  4. Increase testing capacity – Leveraging their unique skills, developers can dramatically increase testing capacity by improving test automation, establishing test data management tools, working on build automation or cleaning up environments. When testing is the constraint – this is a great investment for the team. It can create permanent capacity increases by raising throughput at the constraint.
  5. Refactoring difficult code – If there are sections of code that are tricky to work on or are frequently the source of unintended errors, developers can work to refactor this untested code. It might make sense to combine this effort with increasing the ability to test the code being refactored. Refactoring is particularly compelling when focused on a section of code related to work the team is getting ready to do.
  6. Practice - Increase the capacity and capability of the team by practicing new skills using code katas. There is a craft to being a productive developer. The body of knowledge is large, including patterns, new features of programming languages, new testing and development techniques, and the APIs or interfaces that developers work with. Finding the time to practice new skills on code that will never go into production is valuable when it results in improved capability of the developers.

We need to focus on improving the economic return of developers. Writing code that isn’t needed is not a good economic investment. Writing code that can’t be tested is not a good economic investment. Not writing any code is actually a better economic investment than writing unneeded code or code that can’t be tested. Remember, the goal is not for developers to write code faster. The goal is for the organization to produce valuable, working, tested, remediated product, faster. These two items often collide. Make the best economic decisions – and writing code that can’t be tested is typically not the best economic decision.

Published at DZone with permission of Mike Cottmeyer, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Chirag Visavadia replied on Fri, 2013/09/06 - 7:40am

Great article with accurate pinpointed comments..... Thanks 

Dashell Wieneke replied on Thu, 2013/09/12 - 6:40pm

 Remember, the goal is not for developers to write code faster.  

The goal is write the same amount of code in less time and follow the axiom "If it ain't broke, don't test it".

Has anyone done a study on how much time is wasted by developers testing code that doesn't fail?   If developers spent their time only testing code that does fail, think how productive developers would be.

Alexander Kriegisch replied on Fri, 2014/07/25 - 10:54am in response to: Dashell Wieneke

Dashell, you are just wrong: There simply is no way to know whether code is broken if it is untested.

But one thing in your statement is right: Code you already know to be failing should be fixed first by test-driven bugfixing (TDBF): write failing tests for the buggy code, then fix it. When all tests are green you know two things: that you are done and that the same bug can never reappear as a regression bug because the test harness covers it with tests.

Having said that, I want to emphasise that TDBF is just a small part of the whole picture. The approach you suggested will just produce obscene amounts of junk, rework and technical debt eventually to be paid back with a high interest rate.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.