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.