Why is it so difficult to cleanly finish complex code ?
I mean, why are all complex code so cluttered, with some routines full of hard-coded stuff that makes no sense at all while other routines are so cleanly written expecting the rest to be the same ?
There are some good answers to that and some of them are also good excuses (like lack of time and focus) but my question is deeper, I guess: is there any scenario where none of this excuses makes sense and the result is a perfect code ? Where no one else sees another way of doing it ?
I think this is something like “the dream of software engineers”, to produce a perfect code where you’ll never say later “I could’ve done better” as we always do to our own code two weeks later. The question is, should we run after the “perfect code” ?
Well, my humble answer is a big YES. Not only because I’d like to reach that nirvana level, but because I think we all aquire a lot of great stuff in the path. I can think of some excuses, why they are valid and when they’re not:
Money: Always the biggest of all. When you have a limited budget and a limited team you’ll never be able to make it perfect, specially when you have a business team pressing you to launch anything you got, even if it’s not ready yet.
Time: see money
Resources: When you have too few resources you obviously don’t have manpower enough to do the right code, unless you have infinite time/money, what’s never truth. But, when you have lots of people and lot’s of money and time, the administration of such team is exponentially dificult, and we run for the relativistic problem: each small new feature doubles your amount of money/time needed!
Planning: You can make as many plans you want, everything will be different at the end. I’ve seen many gurus with 30+ years of programming on their CVs getting totally wrong on their planning, even at earlier stages of development. After some point, the more you plan, the more you fail! the problem is to find the point. ;)
Refactoring: This is a good solution for eternal software like the core library of your company’s business (like search core libs for Google) but let’s face it, if you have the freedom to refactor a core library, will you just keep yourself to the basics or would you refactor the whole thing ? Do you think you have the humbleness of accepting other person’s code and point of view ? I would not dare to answer this question…
So, at the end, there will always be a problem in your code because it will always have someone else who will see things in a diferent way! Argh, did I prove myself wrong ?