Friday, March 3, 2017

The code that does not have to be written

Do you know which code is best? It’s the one that does not have to be written at all!

As developers we often solve non-trivial problems. We have to analyze and understand each important aspect of a problem. Then we have to “convert” the result of such analysis into code. This code has to meet all the requirements. It has to be understandable. To achieve this, we talk about design and structure of the code and sometimes challenge it to make it better. And after a while we are there, with a clear picture in our heads. Now the funny part begins, now’s the time for coding!

However, not everything can be set in stone and sometimes, during implementation, we find a better way of solving the problem. Usually I’m against any big changes at this point because of how much it costs Each change means taking the time needed for understanding it, challenging it (probably there will be some flaws), improving it and then modifying code that’s been already written. The bigger the change, the more time and effort it would require. Of course, sometimes there are good reasons for it but in many cases it is nothing more but polishing a solution that does not have to be improved.
Yes, usually I’m against. With one exception - when a new solution requires less. Less code, less concepts, less classes, interfaces. Less to read in the future, less to learn, less to understand.

Domains of our applications are already complex enough. If there’s a way to decrease complexity, I’m always ready to grab it.

It’s good to simplify the existing code, but it is even better to simplify it before it gets written in the first place.

No comments:

Post a Comment