Today I was having another round of conversations with a buddy of mine about the concept of waste and unused code.
In agile there is a concept called YAGNI (You Ain't Gonna Need It) that basically states that you should not add code that is not immediately needed as it is waste.
In Lean software this is known as one of the 7 Wastes of Software. To quote from 'Implementing Lean Software Development'
'The worst of the seven wastes of software development is adding features (read that as simply code) that are not needed to get the customers' current job done.'
The context of our conversation was around code generation. Now I am NOT a huge fan of CodeGen as I have been on the wrong side of a project that used CodeGen. What we were debating was if it was just better to CodeGen up all the CRUD logic (they are using data driven design, not a domain driven approach) prior to needing it or create it as you need it.
The conversation started with this statement from my buddy.
'If I had to go stub a select out for a table, I'd be like WTF. Whoever created this app sucks, they did not even create select procs for me'
When he made this statement I knew I was in for a uphill battle, but I tried to convey my thoughts. However, at the end of the conversation we agreed to disagree (but he is still wrong :)) and we went back to our neutral corners.
So, what are my thoughts on why unused code is waste:
- You are creating speculative code for a need that you may or may not ever realize. And my experience tells me more often then not that code will not be needed.
- There is now more code to be maintained (in his case I have to modify/regen code if my db tables change) which leads to more work in the long run.
- There is now more code to test, which means more tests to fix/refactor when that code changes.
- There is now more code to refactor if you change directions later, and we all know you will change directions.
- Your needs may/will change between the time you originally wrote the code and the time you needed it.
The only real responses he could make were:
- Since this code is created via CodeGen, who cares if it changes I can ReGen it.
My response - This is a weak excuse as re-creating massive amounts of code is expensive and time consuming. Also not mention everyone on the team may not necessarily know/understand how to do the CodeGen
- I do not want to take time later to build the functionality out as I need it. Especially when it comes to things like CRUD proc.
My response - This is about the lamest excuse ever. Creating the functionality as needed, when needed, is the ONLY want to correctly solve your business problem.
So, what lesson have learned here today. Unused code is waste and there is no 2 ways about it.
Till next time,
[----- Remember to check out DimeCasts.Net -----]
08-06-2008 4:21 PM