Bucking the Naming Trend

Posted on

There are only two hard things in Computer Science: cache invalidation and naming things.

– Phil Karlton

I’m sure many of you have heard this quote before but I want to explore one reason why it’s so true: consistency.

Programmers are creatures of habit, ritual and maybe sacrifice sometimes too. It’s impossible for a good programmer to see a list of variables/tables/functions/whatevers like this:

  • calculate_death_star_trajectory
  • close_exhaust_port
  • get_cup_of_tea

and then add to the list

  • fetchThePaper

Seeing mismatched items drives us bonkers because it triggers the bug reflex. You know the one, oohhh that thing is different, it must be the problem.

So what happens when the summer intern comes along to implement a new feature where there is no established list of things and carelessly names the the thing processData_import? (Sure, blame the intern you hypocrite) Then the next person comes along (you come back to the problem you created) and is left with the dilemma: do I clean up the mess or just follow the convention? And because you just want to get on with the feature you came back for in the first place you just stick with the convention and add the second messed up looking thing in the list. The third time now it’s even more painful to clean up all that stuff that uses it now. So it goes.

Another scenario is the one where you’re interfacing the old crusty 3rd party system which had the restriction of only being able to use 10 characters for their column names and end up with things like cntry_cod instead of country_code. Now what do you do? You could just go with the flow and have all your variable names and references to it go along with the standard set before you but then you might end up dreaming of foreign national fish raiding embassies out of confusion. Or you could go with a mapping strategy to get the name out as something that makes sense and remember to put it back into the right place. What a pain though. I try to go with the latter solution when it’s bad enough to justify needing to contain the insanity.

What about those accidental misspellings that get carried along? Yep, I’m looking at you HTTP referer.

All those small innocent decisions perpetuate themselves the longer they’re allowed to live. If you like maintaining your naming sanity, take your precious sweet time naming the first thing and bite the bullet once in awhile to pay down your naming technical debt.

Liked this post?

Sign up and be the first to see new posts!

No spam, no nonsense, no guarantees, no rights reserved, probably.

Comments

comments powered by Disqus