Av rating:
Total votes: 53
Total comments: 27


Jesse Liberty
Programmer Superstitions
11 December 2006

Superstition: widely held but irrational belief (Concise OED).

Ancestor Worship: the custom of venerating deceased ancestors (Merriam Webster).

Apophenia: seeing patterns or connections in random data (Wikipedia).

There are a number of practices that we engage in – no, that we cling to, defend, and teach to others – that amount to one or another of these forms of magical thinking. This is often just fine, no harm done (other than to our self-image as rational geeks) but some of these totemic-rituals are stumbling blocks in our ability to produce reliable software. From time to time we might want to stop and question our most cherished assumptions.

Data Hiding

I’ve been writing in and teaching C++ and C# for fifteen years. I know well the iron-clad rule of object-oriented programming that class data should be hidden (private) and accessed through either a property (C#) or an accessor function (C++). Thus:

public class Employee
{
    private string name;
    public string Name
    {
       get { return name;}
       set { name = value;}
    }
}

There are good reasons for this rule. Data hiding makes for a better decoupling of classes, and allows the programmer to intercept the access of private data and apply rules or other processing. It is possible, for example, to check whether the client accessing a value has the correct permissions to see or modify that value, and also to massage the data in appropriate ways.

But look closely at the example shown above: it is not unusual. The backing data is stored as a private local variable, and full access is provided with a get and a set accessor, neither of which do anything but return or set the value. That is, the accessors add no immediate value at all.

Why do we do this? The last, desperate excuse, as you will find in many computer books, including my own (I add with some chagrin), is that making the backing variable private allows you to change how you store the data without breaking any client of your Employee class. You could, for example, decide some time in the future to retrieve the name from a database.

The rational part of me suspects that the number of person hours wasted, both by making this variable private and by providing do-nothing accessor functions, is swamped by any possible benefit. And yet, I can’t quite bring myself to rewrite this as follows:

public class Employee
{
    public string name;

It looks wrong. It goes against what I’ve been taught and what I 'know' to be correct. It makes me itch.

The problem is that I don’t have a good rational reason not to write this. This is just the equivalent of not stepping on cracks in the sidewalk. One could even argue that the second version is more efficient, easier to understand, easier to maintain, and the risk is vanishingly small (one can always wrap it in a property later, with client classes none the wiser!).

Now, do I have the courage and moral fiber to put that in commercial code? In my next book even?

Ancestor Worship

Let’s take an example where we are not only being irrational, but also making our lives harder and our code more expensive to write and to maintain.

You may want to sit down for this one, but I’m going to dare to ask: why do we insist that C-derived languages (such as C#) continue to be case sensitive? Other than paying homage to Kernighan [1] and Ritchie [2], I believe I can safely say after 20+ years of writing in C, C++ and C# that the disadvantages of case sensitivity swamp the advantages.

The only clear advantage I have ever found is the ability to make the name of a property the PascalCase version of the camelCase name of the backing variable, as we saw above. That is, the backing variable might be employeeName and the property would be EmployeeName, and because C# is case sensitive, these would be considered two different identifiers. This avoids naming the backing variable, for example, _employeeName or some such ugly alternative.

In exchange for that convenience, we enjoy hours of debugging, trying to find where we inadvertently introduced a new variable or method name because of a misplaced shift-key.

Has any bright graduate student done research on the cost/benefit of case sensitivity? Is there any rational reason that in 2006 C# continues this 'tradition' that was established thirty years ago? Or might it be a lingering fear of showing disrespect to the icons of our industry; the mighty heroes who created the C family, defeated Troy and bequeathed us these scriptures by which we live?

Or Maybe Not…

There is an argument that case sensitivity makes more sense with some human languages other than English, and may even make sense as an optimization for some data structures, such as hash tables. Such arguments, however, speak to the need for an optimizing compiler to handle the issue; there is no reason for the language to do so.

In any case, before you write in to me, I’ve stopped caring about the specifics here because Visual Studio goes so far in fixing this problem. I'm just using this more as an example of how we cling to irrational traditions than as a major issue in writing clean code. The truth is, anyone writing C# and who isn’t using Visual Studio deserves the tsuris that results. Anyway, Visual Studio’s Intellisense effectively makes case sensitivity a non-issue.

C++ programmers like to suffer anyway, so this just feeds the beast.

Ancestor Worship II

Here’s another example of latent ancestor worship (or at least of very old habits dying hard). There is a wonderful myth that American standard rail road tracks are the width they are (4 feet, 8.5 inches) because that is the way they built them in England, because that is the way they were gauged by the first tramways, because that is the width of wagon wheels created to fit in the wheel ruts in old English roads that were in turn dug by Imperial Roman Chariots.

The myth has tremendous lasting power (you can find it all over the net) because it feels right [3]. We do that kind of thing a lot; we build the streets of Boston on old cow paths [4]; we unconsciously follow old patterns, even if those patterns no longer make sense or are necessary.

How many times have you seen (or written) code like this:

for ( int i = 0; i < innerArrayLength; i++ )
{
    for ( int j = 0; j < outerArrayLength; j++ )
    {
        myArray[i][j] = i * j;
    }
}

In this example (for those of you who do not spend your time writing C#), the counter variables are i and j. Even those of us who would never dream of using single letter variable names feel perfectly comfortable using the venerable i and j in these circumstances; and have been doing so since we learned to program.

Why, in heaven’s sake do we use these particular letters? Surely a and b would make much more sense. Even x and y might make more sense; but it turns out that in Fortran (remember Fortran? Remember Eisenhower?) the integer variables were the letters I through N (which comes from an even older tradition of mathematicians using i to n as subscripts for integers), and, well, we just got into the habit. This one is fairly harmless, a ritualized and vestigial part of the programming mind that we’re surprisingly reluctant to let go of.

Pattern Recognition [5]

One of the most powerful forms of magical thinking is Apophenia: seeing patterns or connections in random data. The tendency towards Apophenia is probably hardwired into the human brain; it is the price we pay for the very advantageous human ability of pattern recognition (an adaptive part of our intelligence that helps us know when to run and when to hunt) but it can also lead us astray (arguably it is the basis of our belief in many pseudo-sciences).

Apophenia is certainly pervasive in consulting. A classic example was the tendency to study 'excellence' in successful companies in the 1980s; trying to extract those apparent essential elements that lead to success.

Unfortunately, not only was it far more complex and difficult for other companies to reproduce success following these patterns, even the iconic companies themselves felt the worm turn over time. They kept repeating their patterns, but the outcomes were different. What went wrong?

It became clear that the patterns of 'excellence' we saw in successful companies with their great customer service, their attention to employees and small details (as admirable and perhaps as necessary as these efforts were) were actually not as easily connected with success as we had thought. Correlation is not always causation, as we so often learn after losing our shirt.

Software Process Patterns

In software, we’ve identified various patterns of failure that we’ve tried to 'correct' over the past two or three decades. Lack of documentation and communication was 'corrected for' in the promulgation of standards such as CMM and ISO 9000. Unfortunately, this lead to rigidity and an inability to respond to rapidly changing requirements. In turn, this was 'corrected for' with more nimble Agile programming approaches such as eXtreme [6] programming.

In the 1990s, there was a series of divergent and later convergent methodologies offered for creating well-designed object-oriented programs [7]. Learning these 'methodologies' involved a significant investment of time and energy, and advocates of each methodology became highly motivated to demonstrate that their method (and perhaps only their method) would lead to success: 'when all you have is a hammer, the whole world looks like a nail'. There is always a fine line between rationally embracing a methodology that will ensure success of a project, and irrationally clinging to an approach because it is what you know.

We know that personal investment clouds judgment; just ask the scientists who work for Big Tobacco or Big Oil, or for that matter, Big anything!

We have to be wary when following the development patterns of successful software companies, on the premise that they must know the secret. It wasn’t that long ago that the top database was dBase, the top spreadsheet was Lotus 1-2-3, the top Word Processor was Multimate (or was it WordStar…no, maybe it was WordPerfect), and the top compiler was made by Borland. Each of these companies clearly knew how to produce excellent software. After all, their development processes worked at least once.

It simply isn’t clear that you can capture a 'winning' process and reproduce it like a recipe, or that failure to follow the 'recipe' can be shown to be the sole reason for failure of a project. We’re getting pretty good at knowing what doesn’t work (it is always easier to create chaos than order) but not so good at finding what does work consistently.

I recently testified as an 'expert witness' in a civil lawsuit, at which the opposing 'expert witness' asserted that the 'failure' of the project could be attributed to a lack of strict compliance with the ISO 9000 standard.

Smart people can have a reasonable discussion about whether ISO 9000 will improve the likelihood of success on very large projects (e.g. the software for the mission to Mars). I personally would not like to work on a software project that is managed using anything like such a bureaucratic, heavyweight, inflexible, document-intensive, rigid process, but that does not necessarily mean that I can prove that no project would ever benefit from it.

I had no hesitation, however, in asserting under oath that a project with ten developers would benefit from strict adherence to ISO 9000 like a drowning man would benefit from being thrown an anchor. It is my opinion that knee-jerk reliance on a process like ISO 9000 to guide you through each project is a form of Apophenia; the connection between the pattern of ISO 9000 compliance steps and success, however measured, is imaginary.

Looking where the light is

There is an old joke about a man searching for his keys under a street lamp. He lost the keys in the alley behind him, but this is where he can see.

In our desperate attempt to gain control over very complex processes, with so much money at stake, and so many examples of previous failures, we often fall victim to seeing apparent patterns (be they processes or otherwise) where they do not exist. We examine various projects and say: 'Ah ha! I see why this project worked and that one didn’t: the difference was too much/too little analysis/ design/ documentation/ process/ oversight/ communication. And all we have to do is increase/ decrease the number/ length/ duration/ sequence/ complexity/ formality of the meetings/ documents/ diagrams/ studies/ sign-offs, etc.

These false patterns lead us astray; they offer us the promise that if we paint by the numbers, we too can be Renoir. It may be, however, that the variables of successful process are far more complex; including, if we are terribly unlucky, factors over which we have little or no control; or, only marginally better, factors over which we will have no control until our tools and technologies mature.

Or, it may just be that some developers are better at the 'art' of programming and shipping product; and that the old adage '’tis a poor carpenter who blames his tools' applies to software as well as it does to other crafts.

The Scientific Method

Over the years, at least to some degree, society has given up many (though not all) of its superstitions when presented with more compelling alternatives. One of the most effective techniques for distinguishing between superstition and truth (or some approximation of truth) is the scientific method; in short, controllable, measurable, reproducible effects subjected to peer review.

It’s hard to do that sort of thing when you’re trying to hit a deadline, and it’s particularly hard to sort out all the alternatives when there are so few objective comparisons. When was the last time you were able to find anything like an objective answer to the question “which is better: Java or .NET?” (Please don’t write in, my mailbox fills quickly).

It is particularly interesting that the work done at Universities and Research Centers is often not only unrelated to, but totally disparaged by, the folks who write code for a living. That is not the way things work in other Engineering fields and I’m not convinced we can afford the disconnect for much longer. We seem to be writing 21st century software with a 12th century mindset and that can’t be good.

Perhaps we need to put some time into establishing metrics for the software development process; an agreed upon way to measure how long development takes, and how successful are the results. Just defining those two concepts could take a while, let alone figuring out how to measure them. Once we do, however, we could apply these metrics to a variety of approaches and then we could objectively measure, across large samples (to remove confounding variables) which techniques seem to work under various conditions. It would be a start.


[1] Brian Kernighan – according to Wikipedia he is the author of Hello World, and co-author of the first book on C, but denies that he created C, saying “It’s entirely Dennis Ritchie’s work.”

[2] Dennis Ritchie, creator of C, key developer of Unix, and programming icon.

[3] The truth is (as always) more complicated . For a complete examination, take a look at Snopes (a wonderful source for debunking and disentangling urban legends)

[4] Actually, according to William Fowler, director of the Massachusetts Historical Society, this too is an enduring myth, as reported in the Boston Globe on April 25, 2004.

[5] With thanks to William Gibson

[6] See Agile Software Development by Robert C. Martin

[7] See for example Object-Oriented Analysis and Design by Grady Booch, The Object Advantage by Ivar Jacobson, Object-Oriented Modeling and Design by James Rumbaugh, Analysis Patterns by Martin Fowler, Object-Oriented Software Construction by Bertrand Meyer, etc.



This article has been viewed 14653 times.
Jesse Liberty

Author profile: Jesse Liberty

The president of Liberty Associates, Inc and a Microsoft MVP, Jesse Liberty is the author of the international best-selling Programming C#, Programming VB 2005, Programming ASP.NET and numerous other books, including the forthcoming Programming .NET 3. He has written dozens of articles for leading industry publications and has been a featured or keynote speaker at international industry events. Jesse’s biography is listed on Wikipedia and he maintains a political blog a technical blog , and a free private forum on which he provides support for all his writing.

Search for other articles by Jesse Liberty

Rate this article:   Avg rating: from a total of 53 votes.


Poor

OK

Good

Great

Must read
 
Have Your Say
Do you have an opinion on this article? Then add your comment below:


Subject: great article
Posted by: Anonymous (not signed in)
Posted on: Monday, December 11, 2006 at 8:25 AM
Message: Wow. I am 25 years old, 3 years out of school with a Computer Science degree. You mention habits formed in the 80s. I was still crapping in my diapers in the 80s and I still use the techniques you describe. The ones that made me laugh were the data hiding and the i and j variables. I do that for no other reason than my professors told me too. They never gave any explanation other that 'this is the way to do it' and I never thought twice about it. This is the first article of yours I have read and you have earned a bookmark. Thanks.

Subject: Data hiding useful after all?
Posted by: Anonymous (not signed in)
Posted on: Monday, December 11, 2006 at 9:34 AM
Message: Re: "one can always wrap it in a property later, with client classes none the wiser!"

Bill Wagner in his book 'Effective C#' writes "Although properties and data members are source compatible, they are not binary [i.e. IL] compatible. ... this means that when you change from a public data member to the equivalent public property, you must recompile all code that uses the public data member." Apparently, this can be verified by looking at the respective IL. Seems like there is a good reason to hide data members in C#, after all.

Subject: Nice one
Posted by: sal zaki (view profile)
Posted on: Monday, December 11, 2006 at 11:19 AM
Message: Again ... what a great article. Jesse is my man.


Subject: data hiding
Posted by: chrisb (view profile)
Posted on: Monday, December 11, 2006 at 11:38 AM
Message: "empty" property setters & getters aren't a problem anyway - the JIT will just inline them anyway... XML serialisation would be a consideration, but not a big one in the context.

the only real cost you have is to the programmer - and since visual studio will create the property with "prop<tab><tab>" its hardly expensive

chrisb

Subject: Ancestor Worship II
Posted by: Phil Factor (view profile)
Posted on: Monday, December 11, 2006 at 11:44 AM
Message: I still use the i..n characters for my iteration counters for the simple reason that everybody knows what they mean. If I wanted to be a pioneer, and name them to something else, I'd have to document what I'd done every time I used them (actually I, and others, use @ii in TSQL as, for some reason @i looks silly!)

The story of how the gauge of the railways was set is not a myth. It is fact. The earliest railways used standard carts hauled by horses, and it was some time before specially constructed trucks were developed. Obviously, they had to use the standard existing gauge, which was set when the stone tracks were built across Europe. In Britain, Brunel saw instantly the illogicality of the standard gauge, which is why he increased it to the far more logical and scientific seven-foot gauge. Despite the entire Great Western Railway being laid to this gauge, and proving its worth, it didn't catch on. The value of having a universally agreed standard proved to be of even greater worth in the long run. Just like i..n being used for iteration counters.

Subject: Re:data hiding after all
Posted by: JesseLiberty (view profile)
Posted on: Monday, December 11, 2006 at 12:03 PM
Message: Yes, if you are creating a framework (or a dll) that will be used by others, data hiding will prevent a re-compile. Most of us are buidling projects that are all of a piece, that we rebuild all the time, so it doesn't much matter, but your point is well taken.

Subject: Case-sensitiveness...
Posted by: chasbabb (view profile)
Posted on: Tuesday, December 12, 2006 at 5:57 PM
Message: I, too, think that the practice of requiring case-sensitivity in programming languages is counter-productive. We have plenty of letters, and even more letter combinations and words at our disposal, is it really necessary? Human eyes usually don't notice subtle things like "Name" vs "name", and our memory for differences like this are usually worse. I've been programming for over 20 years, and still have found myself pouring over code looking for errors that come about due to a simple differences in case on a variable name. Long live "insensitivity"!~

Subject: Rational
Posted by: Anonymous (not signed in)
Posted on: Tuesday, December 12, 2006 at 10:09 PM
Message: Data Hiding :
More than hiding, I think its a way to visualize your object from the outside - as in how it interacts and what it exposes. At that point in design, it easier thinking in terms of properties which directly gets translated to the g/sets ?

Like the rational thoughts.




Subject: Data Hiding
Posted by: Anonymous (not signed in)
Posted on: Tuesday, December 12, 2006 at 11:08 PM
Message: Accessor functions are convenient for hanging a breakpoint.

Subject: Letters have meaning
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 2:34 AM
Message: "Why, in heaven’s sake do we use these particular letters?"
There are good reasons for this. Math books use a, b, and c for many general equations. Early programmers were very cognizant of mathematics, as that is what "computers" were made to do. X, y, and z are commonly used as spatial co-ordinates and are routinely used for that purpose in computer programs to draw on the display device. As for using i as the starting point for Integers when counting, I can see nothing more intuitive or more succinct.
As for always following tradition, I think the author is doing exactly what he protests: seeing patterns and overlooking facts. What about Hungarian Notation? That was seen as the Holy Grail of variable naming a short time ago, and has fallen to the wayside as programmers found that changing the type of a variable meant a massive search and replace, followed by a complete recompile because one variable outgrew its type's size, or changed for whatever reason.
In the physical world, the foot has gone through size changes, affecting the size of miles and changing entire maps.
The meter/metre has been adjusted to be a small percentage of the speed of light, a constant, instead of the length of a stick of metal in a museam, or so I'm told.
And _everyone_ knows Wordstar was the greatest word processor ever (until WS2000), and Brief (by Underware/then Sage/then Borland) was the greatest editor.
-P

Subject: Data Hiding
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 2:59 AM
Message: I beg to differ on you point they have no use. If you try binding an object to an bindable control you will find that if you DON'T use accessor methods the properties will not display. I agree that it does seem pointless and I wouldn't if I couldn't but that has been my defining factor!

Subject: Please..
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 3:02 AM
Message: I agree wholeheartedly with the first poster, index variables didnt come from fortran, they came from mathematics. You claim a and b would make more sense but you dont say why. Ridiculous.

I guess when I start learning my next, 15th, language I think I'll skip your books.

Subject: Please..
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 3:13 AM
Message: I agree wholeheartedly with the first poster, index variables didnt come from fortran, they came from mathematics. You claim a and b would make more sense but you dont say why. Ridiculous.

I guess when I start learning my next, 15th, language I think I'll skip your books.

Subject: Why not accessors?
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 3:15 AM
Message: You are right to some extent that there should be no blank properties. But then consider scnario in which in a class there are two members m_First and m_Second. and we have to perform some computation while setting m_Second but not in m_First. Should we give property for m_second and direct access to m_First. If yes then for consistant naming of properties we have to rename m_first to First as m_Second has property called Second, which violates coding convention(which is very important). There should be constistant way.

Subject: Bravo!
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 4:51 AM
Message: Stumbled upon your article and laughed out loud, especially reading some of the other 'outraged' comments posted. I happen to agree with many of your points and often felt guilty asking myself the same questions.

Whether you are correct or not is secondary to the fact that it is important to point out these idiosyncrasies and prompt debate so that another generation of developers can examine their practices and decide whats right for them. Too often, we are taught that 'thats how you do it' with no good explanation.

Bravo!

Subject: Data Hiding
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 6:49 AM
Message: I recently learned from Jeff Atwood, codinghorror.com, that changing from a public field to a variable is breaking compatibility and indeed may force changes in client classes. Think about how getters and setters are compiled by the Framework and you'll see that you could break your own code by making the switch from public fields to public properties. The link to the blog post is below.

http://www.codinghorror.com/blog/archives/000654.html

-Brian Chiasson

Subject: Remember what you're generating!
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 8:37 AM
Message: On preview -- Brian Chiasson's post and link covered all the reasons I use trivial properties. This is yet another case where a lack of understanding of the underlying platform causes problems.

Subject: Food for Thought
Posted by: srosenbach (view profile)
Posted on: Wednesday, December 13, 2006 at 9:06 AM
Message: Your very well-written article caused me to stop and think a bit which I think was your reason for writing it. Well done.

Also, I want to praise you for your use of the word, "tsuris." (for those who don't know, this is a great loanword from Yiddish that means aggrivating trouble, pain, suffering, etc.) It is a word that I'd like to hear and see more of in English, and you used it in exactly the right way with exactly the right impact.

Best regards,
SteveR

Subject: Great Article
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 10:22 AM
Message: Interesting reading and for the writer who promised not to read any of your books for his next 15th language, I think it's about time he wrote his own. I own a few of your books and would buy yet another if it is on the next subject I tackle.

Subject: There are good reasons
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 10:42 AM
Message: There are good reasons for each of the behaviors you identify as lacking rational support. Regarding the private/accessor vs. public question, if you don't know why it makes sense, then you haven't ever worked with a legacy code base rife with global variables. Try unravelling a class hierarchy someday where fields/members are accessed publicly in a multi-threaded system, and you'll quickly realize just how important encapsulation is.

Regarding loop variable names, I don't know whether your suggested etiology is correct or not. But I do know this: you offered no rational reason as to why a/b or x/y are better choices than i/j. My personal suspicion is that 'i' was chosen because (1) you're talking about [i]ndex variables, and (2) it leaves variable pairs like a/b and x/y available for more important storage. But whatever the case, you're suffering from the very thing you're out to strike down in stating that a/b or x/y make more sense when, in fact, you offer no rational reason for believing that.

I could quibble with other aspects, but I think the point has been made.

Subject: Concerning Ancestor Worship II...
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 10:58 AM
Message: True, i and j are antiquated for our time, however they are instantly recognizable by any programmer for what they are. Why change to something else, just for the sake of being more "modern"? I'm typing this comment (and I'll bet you typed this this article) on a QUERTY layout keyboard, a layout purposely designed to slow down fast typists so they don't jam mechanical typewriters. The Dvorak and even newer layouts are far more efficient, but I'm not willing endure a learning curve. But that's okay with me. Along this line, check out some of the common English phrases with antiquated pasts that are still used today...

http://www.rootsweb.com/~genepool/sayings.htm

Subject: Case-sensitiveness...
Posted by: chasbabb (view profile)
Posted on: Wednesday, December 13, 2006 at 10:58 AM
Message: I, too, think that the practice of requiring case-sensitivity in programming languages is counter-productive. We have plenty of letters, and even more letter combinations and words at our disposal, is it really necessary? Human eyes usually don't notice subtle things like "Name" vs "name", and our memory for differences like this are usually worse. I've been programming for over 20 years, and still have found myself pouring over code looking for errors that come about due to a simple differences in case on a variable name. Long live "insensitivity"!~

Subject: Great article!
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 4:48 PM
Message: Great great great article, both in content and presentation, i.e. writing ability. I think it's a very good thing to examine why we do things that we just "know" are right.

At first I agreed with you about useless property accessors, but then read the article at Coding Horror someone linked to and I've reverted back to my original thinking. Fields and properties really are different things under the hood even if syntactically they're similar. If the field/property isn't public or protected then I see no problem in using a field over a property, in fact that's what I do now. But if it's publicly available then it's best to make it a property from the get-go to prevent (possible) compilation errors.

As for the i..n iterator variable names, I've started prefixing i to more understandable names. I may use i if it's being used in only one loop, but once I have nested loops I prefix the original iterator plus all the others. It's been too confusing to understand code where I have i, j, k, etc and I forget exactly which loop the letter refers to. Now I have iOuter, iInner, etc, you get the idea. It's wordier than simply i or j but it's way more understandable.

Subject: Yes you are a Bravo
Posted by: Anonymous (not signed in)
Posted on: Wednesday, December 13, 2006 at 11:18 PM
Message: I have been with old and new Programming languages but always the similar questions tickled me, whether you are right or wrong is secondary it raises the self consciousness in the Community what we should follow

Thanks Bravo

Subject: Critical thinking? Absurd! ;-)
Posted by: Anonymous (not signed in)
Posted on: Thursday, December 14, 2006 at 7:28 PM
Message: Sometimes, it's worth the effort to look at the things we've always done and question them just as you have done in this article. Nice job! I especially like the "process" discussion. It's quite well known to those of us in the trenches that process doesn't make good software, good programmers do. All process can do is help those good programmers be efficient (when used appropriately and in moderation).

I do have comments on the two "Ancestor Worships," though. First, don't rail on the programmer for using "i" and "j" as loop variables because they come from FORTRAN. "i" and "j" were already terrible variable names in the FORTRAN days because they didn't describe themselves. "MyArrayRowIndex" and "MyArrayColumnIndex" would be much better. (OK, FORTRAN variables were too limited in length for these names. But it certainly wasn't limited to a single character.) Though your underlying point is well taken.

Second, in my opinion, differentiating variable names by case alone is just asking for trouble for exactly the reasons you described. I prefer to code as if the language were already case-insensitive and not duplicate variable names if the only difference is case. (I personally use the ugly leading underscore for private member variables, but to each their own. ;-) ) Not only does it help prevent future confusion, but it makes it easier for me to switch to VB and other case-insensitive languages when I need to.

Subject: FixedAssetManagement
Posted by: Anonymous (not signed in)
Posted on: Friday, December 15, 2006 at 3:23 AM
Message: I want gave you show database design about Fixed Asset Management becuase I write Sarana about it and I don't know about fixed asset.

Subject: I (or i) is for iterator
Posted by: Anonymous (not signed in)
Posted on: Sunday, December 17, 2006 at 5:22 PM
Message: As someone who learned maths when we started with axioms and fundamentals rather than the confused modern approach, I would like to comment on the use of i, j, and so on for iterators.

Mathematicians used a, b, etc. for irrelevant numbers of fixed value, because when you're looking for a general solution to a problem, actual numbers confuse the issue. They used the mysterious x for unknown quantities, generally the thing one is trying to evaluate (because it's the least-used letter of the alphabet? - I don't know). And they used i as the starting case of an integer series because it's the first letter of "integer".

Next step: Fortran used I to N to indicate integers (because N is the second letter of "integer"? - your guess is as good as mine). BASIC followed in this path. Both languages rectified this strange convention, eventually, allowing explicit type declarations.

As for using these as identifiers, I don't, ever. The most frustrating three hours of my life were spent trying to decipher a bit of code which iterated through a three-dimensional array using i, j and k as variables, and it turned out that somewhere in the depths of multiple layers of code these were day number, commodity category and price per tonne - but before I figured that out, I couldn't modify the behaviour as I needed to, and if the names had been meaningful in the first place, I would have been spared hours of ferreting.

Case-sensitivity is simply bad. One of my favourite Visual Studio IDE features is that if I type a line of VB without case and press enter, then if the line is semantically correct, the case changes to the way variables are declared and language keywords are defined. If this magic doesn't happen, I have a syntax error to find. And I don't spend frustrating periods trying to find a mistyped letter! The wastage of time finding such trivial issues in Javascript, C#, etc. rather annoys me.

Enter your comment here:

  Name: 
  Subject: 
  Message: 
 
 

















Level Playing Field
 The Federal Government in the States accepts tenders for their IT projects from a wide-range of... Read more...

Second Life: A Virtual World of Real Money
 As more and more people invest in alter egos to live a pseudo life online in Linden Labs' latest... Read more...

Risking your Reputation
 IT companies sometimes don't survive an incident that damages their reputation. Often, when... Read more...

Bad CaRMa
 From hope and euphoria, to desperation, firings and the ultimate demise of a company. Tim Gorman charts... Read more...

Free Phil Factor eBook: Confessions of an IT Manager
 Download a 108-page eBook in which Phil tells all on a career spent in the rough-and-tumble of the IT... Read more...

Linus Torvalds, Geek of the Week
 Linus Torvalds is remarkable, not only for being the technical genius who wrote Linux, but for then... Read more...

Driving up software quality - the role of the tester
 Have you ever wondered what a software tester does? Helen Joyce, test engineer at Red Gate software... Read more...

Coming Out as a Cancer Survivor - A Guide for Software Developers
 A personal perspective on the responsibilities of a cancer-surviving software developer Read more...

The Computer that Swore
 Database Developers occasionally get crazy ideas into their heads. Phil Factor should know; He... Read more...

The Writing on the Wall
 Phil Factor offers an intriguing theory on why so many, hugely complex, government IT projects fail. Is... Read more...

Over 150,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.

Join Simple Talk