The simpler the better
The simpler the better, that’s something that we usually forget when we are developing software, lots of times we are tempted to use design patterns/frameworks/technologies/tools… without considering other simpler and less fancy options. If there are two ways to implement something and if they are equally functional and don’t add any repetition to your system, pick the simplest solution.
Considerations for not adding complexity to your project
If all you have is a hammer, everything looks like a nail
This is a common bad habit in developers that have just learn something new and they are anxious to apply it. Suddenly everything fits this new technology/tool/framework… Here are some examples:
- ESB: “Let’s communicate the backend layer and the UI layer of this desktop application through the ESB!!!
- Spring: “I have to create the class car, and it has 4 doors, I will better assign that dependency through Spring!!!!”
Because you can, it doesn’t mean you should
This is common in senior developer that are eager to show how advanced their designs can be. Example:
- Abstraction: “The board class for this chess game software is too rigid. I will change it so that it will be a dynamic 2D grid which will allow us to create chess boards of 12*12, 4*6, or any other arbitrary dimension”
The more things that can fail, the more things that will fail.
There’s something that every developer must always remember. We always make errors. The number of errors we make is proportional to the number of things we develop and their complexity. So the safest path is not to write code at all or not to add complexity.
The more prepared is your code for change, the more difficult is to change your code.
This is a paradox which I believe I read in a Kent Beck book, (I think it was in “Xtreme programming explained”, if someone could please confirm this in a comment I will appreciate it very much).
It is a common scenario when a developer proudly shows some code and explains that because of his design, any future changes related with his class can be handled through configuration. Three months later, the first change request not only shows that the current code needs to be changed, but because of over-engineering, extra effort in refactoring is going to be necessary.
Add complexity if… makes things easier!
I hope I am not sending the wrong message with this post, I’m not saying that using frameworks/tools/new technologies… is bad, I’m saying that if not used appropriately the complexity they bring takes over any flexibility they may offer. So the key is to know when to use them. Here you can find three tips that may help you.
Use them to get rid of some duplication you have in your code.
This is one of the most legitimate causes to add a tool/framework/technology to your project, duplication makes your code maintenance a nightmare.
Use them because of the flexibility they provide
Spring, Hibernate and other frameworks are examples of frameworks that are great when you need flexibility.
Use them because is easier to use them than to implement their functionality by ourselves.
If you need a unit testing, don’t write your own, use any of the xUnit or TestNG, for example.