Would you go to war without a helmet? Would you drive without the seat belt? Then why do you develop software as if it shit doesn’t happen?
Meet Martin (an average developer) and John (a great developer) Martin is reviewing John’s code:
-Hey John, why do you validate the value of this parameter in your method?
-Well Martin, this is a public method and I’m making sure that its value it’s either “A” or “B” some other value will be invalid.
-I know John, but my class is the only one calling the method and I know I’m only passing “A” or “B”.
-Martin, have you ever heard about HDD?
The previous conversation is a fictitious one, but I’m sure you have been in a similar situation. HDD is the approach to software development where decisions and code are made based on assumptions and guessing
HDD does not only apply when coding, it applies to all the stages of software development, I remember been in a design meeting for a new interface to an external system, the documentation we had was minimal, so we didn’t really know what we were supposed to develop, what did we do? We just guessed what the implementation should be, so when we had to integrate with their system…. CRASH!!! Total disaster, we had to rewrite lots of code.
Everyone realizes HDD is bad, but we all still keep doing it, the only explanation I have for this is that Software Developers are extremely optimistic, is like when we have to give an estimate, 90% of the times our first estimation is: “It shouldn’t take more than one day or a few hours”, which is the same sentence you are going to repeat for the next week.
Most of the bugs I’ve seen During all the years I’ve been developing software were caused because HDD. I’ve come up with a list of symptoms to detect when HDD is being used and a list of tips to prevent it.
Symptoms that you are using HDD
- You use words like: “should”, “I think so”…
- You don’t have unit tests.
- You are more concerned about performance than your code quality. That’s one of the common traps, it’s usual to find developers arguing that they don’t want to add an additional validation, or some logic for error handling because that will cause bad performance, that’s wrong, what we should do is first make the best code as possible and then optimize it for performance, 9 out of 10 times the performance is not affected.
- You don’t have frequent demos/reviews with your product owner/team.
Tips to prevent HDD
- Every time you hear “should” or “think so” translate it to “I don’t have a clue”.
- If it doesn’t have unit tests, is not done.
- First care about your code quality, then improve the performance.
- Communicate, communicate and communicate.
What do you think?
So what would you do if you were John in the fictitious conversation above, what will you say after all:
a) HDD is just stupid, remove the validation, that’s unnecessary.
b) I see! We have to prevent HDD, let’s keep the validation.
Please let me know what you think in your comments, I’m looking forward for your opinions.