Re: How to name variables in a program?




<Jens.Toerring@xxxxxxxxxxxxxxxxxxx> wrote in message
news:3fudarF9ja99U1@xxxxxxxxxxxxxxxx
> spinoza1111@xxxxxxxxx wrote:
> f

>
> Just have a look at the source code in what seems to be the original
> paper by Simonyi at
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs600/htm
l/hunganotat.asp
>
> (it's somewhere at the end of the page). The source code gives you
> no indication at all what it does since neither the function nor the
> variable names tell you anything about their purpose. In contrast to
> the intention of the author it's probably difficult to come up with
> an example that more clearly shows why HN is completely useless and
> actually counterproductive.
> Jens

The code was, presumably, intended as an example of how to name various
elements in a typical 'real life' program and not as a demonstration that
comments become redundant once HN is used (which of course they don't). I
would have thought that HN was put forward as a simple dogma to formalise
the naming of variables that everyone could understand and hence avoid the
minimalists' approach to nameing (x, y, z, i, i2, etc.), the wordy
(x_amount, value_y, zAxis, i_count, i_count2, I2Count, etc.), etc. I think
that it's safe to assume that this code was a pre-existing example that was
either fairly cryptic or very long-winded before the HNotation was applied
to it.

If you take the time to read the code line-by-line (as you would if you were
going to actually work on it), then the naming convention is the least of
your problems. It's interesting to note that there are at least 2 cut/past
errors in it. This has gone unnoticed because the general layout,
regardless of nameing convention, is extremely bunched up and ugly. Limited
use of whitespace, lack of bracing for single-line loops, etc.

I'd be interested in seeing how each poster here would have named and layed
out that code example. And then again, how they would have done it in a
production environment with the schedule pressure.

In reality, you get used to most things as long as they are consistent.
Having said that, I'm most annoyed working with programmers that don't
enougth space characters. E.g. for(i=0;i<10;i++) I don't know they write
like that, they wouldn't write without spaces in written English.


.



Relevant Pages

  • Re: how to know if the Stored procedure is used to retrieve data or not
    ... For example you can name your procs ... If you don't have a naming convention and you need to determine what ... Script all the SPs using Enterprise Manager and then ... inspect or search the source code. ...
    (microsoft.public.sqlserver.programming)
  • Re: Christmas Update Predictions
    ... Now that he has a real life with ... to spend another thought for roguelikes. ... because the source code is hard to maintain and develop. ... and think there is no problem releasing it to the world. ...
    (rec.games.roguelike.adom)
  • Re: Why Case Sensitive?
    ... far more advantages in ignoring letter case in source code. ... In real life such a situation would be ridiculous (eg. the 16 ways ... C is case sensitive because computing systems are naturally case ... output devices, text utilities, typesetting systems etc. ...
    (comp.lang.c)