Egoless Programming #4: Don’t rewrite code without consultation.

In 2001, Lamont Adams of TechRepublic chiseled what would become ten commandments of Gerald M. Weinberg’s timeless wisdom: Egoless Programming.

Today we’re going to learn its fourth commandment:

Don’t rewrite code without consultation.

Have you ever opened a source code file only to experience a visceral reaction? Had the uncontrollable urge to apply a bit of scorched earth engineering? Stop. Back away from the keyboard. Breathe.

Find the code’s author, buy them a cup of coffee, and have a chat. Here’s why:

Quick PSA: Refactoring != Rewriting.

Before we jump in, I want to handle this common objection.

Yes - you absolutely should be improving the codebase through continuous incremental refactoring. Refactoring improves existing code through controlled micro changes. Rewriting tosses existing code in the trash and starts over. The latter requires a conversation.

Question: Does the code work?

Does the code need to be changed? Or do you just not like it?

There’s almost always a better or more idiomatic design than what you see on your screen. But if the code passes its tests, performs acceptably, and provides the necessary customer-facing functionality, it might just be good enough. And your effort might be better applied elsewhere.

Question: Do you know the rationale behind the code?

There just might be an excellent reason for the current design.

Rather than assuming you have superior programming skills, assume the original author has superior knowledge of the problem domain. Obscure edge cases? Finicky upstream data sources? Awkward client APIs? These are all possible reasons the design might seem a little off.

Question: Are you aware of your opportunity?

You can either learn something or teach something!

If the original author has superior knowledge of the problem domain than your own, you’ll walk away from your chat a little bit smarter. If instead they need to be mentored in design techniques or language idioms, you now have an easy teaching opportunity! It’s a win-win for your team either way.

Question: Have you scheduled that conversation yet?

Don’t waste this opportunity to make you and your team stronger!

Previous
Previous

Egoless Programming #5: Treat people who know less than you with respect, deference, and patience.

Next
Next

Egoless Programming #3: No Matter How Much Karate You Know, Someone Else Will Always Know More