Developer

Egoless programming: The path to better code

Lamont Adams discusses the virtues of egoless programming and The (Almost) Ten Commandments necessary to achieve it.


In “The case for informal peer review in a development organization,” we explained why an informal peer review process is a necessary evil in your organization. But how do you deal with such a process? In our previous article, we suggested that programmers, like artists, often have trouble looking objectively at their work and can benefit from constructive criticism. Taking the programmer-as-artist analogy a bit further, I would imagine that most artists would rankle at the idea of other artists poring over their efforts while they worked, criticizing their choice of pigment or brush stroke. The artist would naturally become offended at such pretentiousness. This is precisely why so few art masterpieces in history were created by a committee.

Something similar often occurs when someone questions a programmer’s method of solving a problem. We’ve all seen the intricate eggshell dance performed by a coworker attempting to approach a developer with a serious problem in the developer’s work. Should such lengths be necessary when dealing with a professional? What is needed is a way for developers to distance themselves emotionally from their work so that they become open to criticism, often from individuals with less perceived ability. Enter egoless programming.

Part state of mind and part QA philosophy, the term “egoless programming” was coined in 1971 by Gerald M. Weinberg in his book The Psychology of Computer Programming (ISBN: 0-932633-42-0, Dorset House Publishing). Weinberg was explaining a debugging philosophy that made heavy use of peer technical reviews, and he used the term to describe the mindset developed by programmers working in such an environment.

Obviously, we need to set some ground rules or guidelines to be followed in order to create the kind of environment necessary for programmers to share their work without fear of ridicule or rebuke. To that end, I present The (Almost) Ten Commandments for egoless programming.

The (Almost) Ten Commandments
  1. Understand and accept that you will make mistakes. The point is to find them early, before they make it into production. Fortunately, except for the few of us developing rocket guidance software at JPL, mistakes are rarely fatal in our industry. We aren’t surgeons; we can learn, laugh, and move on.
  2. You are not your code. Remember, the entire point of a review is to find problems, and problems will be found. Don’t take it personally when a problem is uncovered.
  3. No matter how much karate you know, someone else will always know more. This fact kept the samurai from indiscriminately attacking people in Imperial Japan. In our less violent times, such an individual can teach you some new moves if you ask. There will always be people who know more than you. Seek and accept input from others, even when you think it’s not needed.
  4. Don’t rewrite other programmers’ code. There’s a fine line between “fixing other programmers’ code” and “rewriting other programmers’ code.” The former implies that a bug or other functionality problem exists and needs to be fixed and can also refer to correcting gross readability problems. The latter, however, refers to changes made to code for the sake of style. Programmers fresh from college are often guilty of this. Things like renaming variables, use of a different construct, recommenting, or gratuitous reformatting of white space fall into this category. Such activities, even with the purest of motive, are high hubris and detrimental to team mentality.
  5. Treat people who know less than you with respect, deference, and patience. Nontechnical people who deal with developers on a regular basis almost universally hold the opinion that we are prima donnas at best and crybabies at worst. Becoming angry only reinforces this perception and teaches people to avoid asking questions. This can only harm your work in the long run.
  6. The only constant in the world is change. Be open to it and accept it with a smile. Look at each change to your requirements, platform, or tool as a new challenge, not as some serious inconvenience to be fought.
  7. The only true authority stems from knowledge, not from position. Knowledge engenders authority, and authority engenders respect—so if you want respect in an egoless environment, cultivate knowledge.
  8. Fight for what you believe but gracefully accept defeat. Understand that sometimes your ideas will be overruled. Even if you do turn out to be right, don’t take revenge or say, “I told you so” more than a few times at most, and don't make your dearly departed idea a martyr or rallying cry.
  9. Don’t be “the guy in the room.” Don’t be the guy coding in the dark office emerging only to buy cola. The guy in the room is out of touch, out of sight, and out of control and has no place in an open, collaborative environment.

Following these rules will prevent needless eggshell walking by your coworkers and will allow them to get back to the one activity everyone in this profession enjoys: creating great things with their computers.

Editor's Picks

Free Newsletters, In your Inbox