Third, we need to understand the consequences of our actions. When one has to change something they don’t understand, it starts getting stressful. Nobody wants to work under stressful conditions when developing, testing, deploying, do they?
What do Experts Say?
Software engineers want to rewrite code in a large portion of cases. This is a result of our natural desire to do our job better. Here’s what Joel Spolsky, a creator of Stack Overflow, wrote 20 years ago:
“The reason that they [programmers] think the old code is a mess is because of a cardinal, fundamental law of programming: It’s harder to read code than to write it.
This is why code reuse is so hard. This is why everybody on your team has a different function they like to use for splitting strings into arrays of strings. They write their own function because it’s easier and more fun than figuring out how the old function works.”
Whenever new developers onboard a project, they find the existing code too complicated and want to rewrite it. “As a corollary of this axiom [that code is more easily written than read], you can ask almost any programmer today about the code they are working on. “It’s a big hairy mess,” they will tell you,” he says.
The thing is, nobody wants to do the unpleasant part of the job, which is dealing with legacy code or onboarding a project. “Fixing bugs isn’t fun; going through the bug list isn’t fun; but rewriting everything from scratch is fun (because “this time it will be done right”, haha)…”, Jamie Zawinski writes.
So, as you see, developers want to rewrite something fairly often. But one should be pragmatic and think twice before taking action.
A Word on Engineering Ethics
When becoming a doctor, one takes the Hippocratic Oath. One of the things they promise with it, is the serving of the interests of patients first and foremost, as opposed to their own concerns.
When becoming a programmer, we don’t take any oaths (not yet), but we do have our professional Code of Ethics put downin black and white, and one of its postulates is essentially the same: “Principle 2: Software engineers shall act in a manner that is in the best interests of their client and employer consistent with the public interest.”
The bottom line is that pursuing personal interests instead of business goals is considered unethical. So, before asking for approval for rewriting the code, make sure you pursue the interests of the product and the customer, not your own.