A nugget from Uncle Bob's Clean Code.
Computer programs should be in such a way that it not only makes things work but also makes it easier to modify it( for various reasons like fixing bugs, modifying logic, adding a new feature). Unlike good code, the bad code does the opposite i.e. makes everything difficult. “It was the bad code that brought the company down”, says Robert C. Martin in his bookâ€Š–â€ŠClean Code.
The primary reason for writing bad code into software programs is “Deadline”. Thoughts like “If I don’t do what my manager says, I’ll be fired”. Probably not. Most managers want the truth, even when they don’t act like it. Most managers want good code, even when they are obsessing about the schedule. They may defend the schedule and requirements with passion, but that’s their job. It’s your job to defend the code with equal passion.
To drive this point home, what if you were a doctor and had a patient who demanded that you stop all the silly hand-washing in preparation for surgery because it was taking too much time? Clearly, the patient is the boss; and yet the doctor should absolutely refuse to comply. Why? Because the doctor knows more than the patient about the risks of disease and infection. It would be unprofessional (let alone be a crime) for the doctor to comply with the patient.
Similarly, going by that analogy, it is unprofessional for programmers to bend to the will of managers who won’t be able to understand the risks of making messes. And most importantly, you will not make the deadline by making the mess. Indeed, the mess will slow you down instantly and will force you to miss the deadline. The only way to meet the deadlineâ€Š–â€Šthe only way to go fastâ€Š–â€Šis to keep the code as clean as possible at all times.
To sum it all up, control your urge to write bad code to meet deadlines. Deadlines are always there! Instead of writing bad code and meeting deadlines prefer writing good code even if you miss deadlines. Practice explicitly and deliberately to write clean code.Soon, with practice, you’ll become so fluent in writing clean code which will enable you to stay on track and finish on or before the deadline.
Happy Coding !!