Code Cleanup (3 Part Series)
"A naively formulated goal transmutes, with time, into the sinister form of the life-lie.", writes Jordan B. Peterson in his book - 12 Rules for Life.
In the same book, he also explains what a life-lie is. To my understanding, a person living a life-lie is someone who is living their life premised upon a particular idea which supports only one preferable, narrowly defined and overly specific outcome.
The problem is in the rigidity of the expected outcome. Being rigid about your opinions, expectations and beliefs can rarely be a good and positive thing. Regardless of the context.
The same premise applies to programming. So, let's understand the root of this problem. How do you recognize a naive developer (and potentially see if you are behaving like one)?
A naive developer is a one which believes that his current knowledge will forever be well grounded and conclusive. Therefore he designs and architects the code structure in such manner that it only solves a specific problem he acknowledges. He refuses to forsee any other course of action and flow of the program. He is trapped in his own petty beliefs and ideas.
He is effectively blind.
A naive developer can easily be caught while pair-programming. He is a person who will continuously impose his own ideas without giving their partner a chance to present their own views on the issue at hand.
Approaching problem from a one-point-perspective, he will inevitably be forced to bend all of the forthcoming code out of shape, and into his poorly constructed mould. And this is where things start to get really unpleasant for a naive developer.
His unadaptable opinions created a code monster to deal with. The endless refactorings (if he even recognizes that is appropriate) will not be of much help. He must redesign the system.
But the real issue is not the code he created. It is his mindset and approach to the problem. If he doesn't take the responsibilty to see his own failures, he will continue creating code monsters in each problem he tries to solve.
So this is the part where you think about your approach to problem solving.
You should always keep reasking yourself : what is truly the problem I am aiming to solve? Getting stuck in the development rut is something every developer encounters from time to time. That is precisely why we should always develop with our one eye open, waitting to catch ourselves in our wrongdoing.
Ask for a second opinion (at least). Trust someone with a fresh view on the problem. Listen to their ideas and propositions. Discuss the possible outcomes.
Seriously. Going on a 10 minute break can give your mind some space to rethink the problem you are solving.
Last but not least, admit and correct a mistake when you know you had made one. Do not keep pushing an idea beyond its scope. A good sign you might be naively programming is too much (truthfully, any) hacky business going on.
To an engineer, the idea of making a mistake, especially one which implies a big analytical mistake, is hard to swallow. But it is something necessary to do, for the sake of efficiency and productivity.
Please give me your opinions and experinces related to this topic. I would love to hear them! Have you ever been a naive developer? Have you worked with one? What was the outcome?