Your Name Stinks

Say you work on a software project with a guy named Doug and he implements a very clever search algorithm. Excellent. He deserves to take credit for his invention. He is also on the hook for fixing any bugs that crop up in it. It’s likely that other people on the project will informally refer to this piece of code as “Doug’s search algorithm”. All well and good. However, it would be troubling to open up the checked-in source and see it implemented with the following function.

def dougs_search_algorithm():
    // ...

Is Doug the only person who is allowed to run the code, or the only person allowed to modify it? Do we expect it to stop working when Doug moves on to another project, or merely to not work as well? Is some essential component of Doug’s personality reflected in the algorithm? Do you have to be personal friends with him in order to understand it? If the answer to all of these questions is “no”, what exactly is this naming convention telling us?

Proper names have no place in source code. Their presence is a variety of code smell: specifically, a worrying sign that the developers have not considered the possibility that their work might be used by someone outside their circle of personal acquaintances. Which in turn is a sign that either this is one-off work not intended for public consumption or–worse yet–it is intended for public consumption, but was written without sufficient appreciation of how difficult writing code for public consumption is. If a person’s name, email addresses or user ID shows up anywhere in text that a compiler will process, be leery. If you see a path to someone’s home directory written into source code, walk away and don’t look back. The only exceptions to this rule are the names of programmers and mathematicians who have passed into the general pantheon. You are allowed to have a class called DijkstraSearch in your graph library, because there is no danger of someone thinking that it is being maintained by Edsger Dijkstra himself.

Source code is, like facial hair, a poor medium for personal expression. Feel free to write your name all over the version control logs–that’s what they’re for–but in the code itself strive for an air of calm, authoritative anonymity.

Advertisements
This entry was posted in Those that have just broken the flower vase. Bookmark the permalink.

2 Responses to Your Name Stinks

  1. Fred says:

    Timsort?

    • W.P. McNeill says:

      Tim Peters may have earned himself a place in the pantheon with his algorithm and so gets a pass. Now “Timsort” is just term of art. But even if you write an algorithm that will eventually make you famous, you can’t know that it’ll make you famous at the moment you check it in, so proper names are still dispreferred unless you’re psychic.

      As an aside, @trochee tells me that Page Rank is actually named after Larry Page instead of meaning “an algorithm for ranking web pages” as I had always thought. This is a clever pun, and so may be counted as a rare exception to the rule that programmers aren’t funny.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s