Sunday, February 15, 2015

Customs in Coding Style

"What's in a name? That which we call a rose
By any other word would smell as sweet.
So Romeo would, were he not Romeo called,
Retain that dear perfection which he owes
Without that title. Romeo, doff thy name;
And for thy name, which is no part of thee,
Take all myself.
"
-- Shakespeare, Romeo and Juliet
Act II, Scene II, Lines 43-49.1

Recently for a lunch and learn at work my team re-watched Clean Coders episode 2: Names++.  As with all Uncle Bob videos I highly recommend it.  Being a developer who programs a bit in C# I do have to disagree with his statements about bucking the convention of starting interfacing with an "I", the example he gives is IAccount vs Account.  I agree with most of what he said and having programed in many other language I completely agree that the "I" does not add any additional information but I still use it when I program in C#.  Why?

"Pindar was right, in my judgment, when he said, '[Custom] is the king [over] all.' "
-- Herodotus, The Histories
Translated by George Rawlinson
Book III

Custom is king of all.  I strongly believe that if there is a current naming standard in a language you should just follow it.  When I am doing C# in Visual Studio whatever ctrl+k ctrl+d does is the standard I follow (for the most part).

Why?  Source code is for humans to read and understand, all groups, peoples, languages, ... have customs.  These customs are often built into the communications patterns that are followed and are implied by parties taking part in the communication.

Do not believe me, how would I order a Coca-Cola where you are from?  I grew up in the Chicago area, my whole life people referred to all soft-drinks as pop.  I currently work in Milwaukee guess what they call soft-drinks?  In Milwaukee a soft-drink is called soda.  As a kid I vacationed in the Ozarks, what do you think they would call a soft-drink?  All soft-drinks in the southern part of Ozarks were referred to as coke.  There is a whole website which covers all this pop VS soda VS coke.

What is my point?  When coding in a language if you want other people who program in that language to understand what your code is doing with the minimal amount of effort you should just follow the existing standards of the language you are coding in.

There are lots of other place in software development to have a style and flair, bucking current language naming standards is not the place to do it.

"[I]f one were to offer men to choose out of all the customs in the world such as seemed to them the best, they would examine the whole number, and end by preferring their own; so convinced are they that their own usages far surpass those of all others."
-- Herodotus, The Histories
Translated by George Rawlinson
Book III