Home > Extreme Programming, General Software Development, Software Development > Name a variable like you name your first-born

Name a variable like you name your first-born

Jonathan Cogley: Code Naming

April 13th 2009 | Jonathan Cogley

Name a variable like you name your first-born

“You should name a variable using the same care with which you name a first-born child.”

– James O. Coplien, Denmark   (foreword to Clean Code)

This is hysterical!  I had such a good laugh on reading this line.  For those developers who don’t have children – the child naming process can take months … it usually starts in the second trimester (3-6 months of pregnancy) and can still remain undecided when the child is born… having been through this twice, it is not an easy process.

Note that James doesn’t say naming of a child but rather your first-born implying even more care and emphasis!  While this is obviously in jest, it does highlight how important naming and concepts can be within your code.  With our team, naming a variable can sometimes take 5 minutes while the programming pair argues backwards and forwards. If it takes too long we give it some silly name (bunnyFooFoo) and move on with the intention of revisiting the discussion during code review before committing to the source repository. Besides, who would let bunnyFooFoo go into the source repository with their initials on the commit?

Next time you whip out a string “s” or int “i” or DateTime “d”, give a thought to a logical name that will help others to understand the code in future.

Further thinking on naming:

Jonathan Cogley is the CEO of Thycotic Software, an agile software consulting and product development company based in Washington DC.  Secret Server is our flagship enterprise password management product.

  1. April 15, 2009 at 9:14 am

    This blog really made me laugh – and I’m not even a programmer. (Nor do I have a first-born – unless you count my dog.)

    But it’s impossible to look at that photograph and NOT read the blog!

  2. May 7, 2009 at 11:36 pm

    Very nice… I’m in a book club currently going through Clean Code & find naming very interesting. This is especially true when involving business analysts. Even more true when working with Brownfield application development. Names are hard to change once they gain footing.

  1. April 16, 2009 at 3:27 am
  2. April 16, 2009 at 5:04 am
  3. April 21, 2009 at 4:40 am
  4. November 28, 2009 at 7:38 am

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

%d bloggers like this: