Simplicity or not at all
Some of you might know by now that simplicity is the most important development metric for me. That’s because I have seen so many times what can happen to complex code and it isn’t nice. Complex code is harder to understand, difficult to maintain, nearly impossible to extend and downright ugly.
Complexity
Some developers tend to over-complicate a task and ends up writing too many classes to solve a simple problem. The ability to take a step back and observe the problem space before digging in to a detail is hard, but it will keep you from over-complicating matters. The more experience a developer have, the easier it becomes to find out how many steps backwards to take in order to fully understand the problem space.
Should you end up with a complex solution, then you must learn to identify it before moving on to the next task. If you are in doubt about the complexity, then it is too complex. You have to be able to say “this is a nice and simple solution” otherwise it probably isn’t.
Don’t mistake simplicity for something that only fixes simple problems, while a more complex solution is needed for complex problems. That is not the case. Simplicity can be applied to all sorts of problems no matter how complex they are. That’s because simplicity exists in the problem space or application scope and not within the problem itself.
It is absolule but subjective
Just because a problem space is relative in size doesn’t mean that simplicity is also relative. Simplicity is a constant and it is applicable to every piece of code ever written. If it was relative then each developer could define how much and thereby have an argument for writing complex code.
The problem with simplicity is that it is subjective. There are no tools that can analyze your code and tell you if is simple enough. Some tools try, but none succeed. So it’s all up to the developer to decide anyway and that is too bad. Code reviews does help a bit, but only a bit.
Know your limitations
I’ve always believed that if you cannot find a simple solution then don’t do it at all. That’s because if you cannot take a step back and get a good feeling for the problem, then you don’t understand it enough to see a simple solution – and trust me, there is always a simple solution. If you don’t understand the problem you are trying to solve, then you probably cannot solve it. It would be like saying “my car makes a strange sound, I think I will remove the engine to see if it makes it stop”. That’s not the best idea. Then it's time to ask for help understanding the problem.