Re: global variables are bad?



On 2006-03-12, Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx> wrote:
Richard G. Riley schrieb:
On 2006-03-12, Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx> wrote:

Having seen identifiers which consist of five letters Hungarian
abomination and one or two letters "name" in order to keep the
6 letter limit, I cannot really claim that I am convinced.
Interestingly, even MS abandoned HN.

When reading code from a printout I like it. In a code environemnt, no
need since the tools show the type.

But Hungarian was not what I meant to be honest : I was too hasty and
annoyed from the other thread.

Happens :-)

Whyt would you call this in the academic world?

CStructMine *ptrDate = &myStruct;

int numRollsOfTheDie = getRolls();

Possibly "loose hungarian" or just "common sense good naming"?

I'd go for the latter. In the company I am working for at
the moment, the "naming conventions" go like that (parts of
that are C++, but there is only one set of conventions):
Start with 'p' for pointers and 'r' for references, accumulate
'p's and 'r's appropriately, with 'm_' for members and 's_' for

I hate m_ for members. There is "this" and the anchor object to
indicate that they are members. Es ist genug.

static members, do not use gratuitous '_' (essentially: Keep it
to the macros), use camel casing for member functions and
Pascal casing for other functions. Make the names telling.

"telling" can be difficult across languages (world), but at the end of
the day I've worked on many projects around the world and the code
language was in all cases, bar one, in English. Made for some pretty
freaky comments : we'd have been better off without them IMO:)

In the case of libraries from different products, one also
gets some name prefixes, too, but these are not annoying.
There is some more stuff for enums, typedefs and classes but
that's about it. Personally, I'd even use less regulation
in some parts but this is about okay. When talking to the
oldstyle Windows programming disciples, I am very glad about
this set of rules in comparison.

On
more than one project we introduced some basic naming standards and
the productivity soared : really. Far easier to see type and use even
just adding "ref" or "ptr" to a variable name : one of the biggest
causes of issues in C/C++ code reading and function calls

Yep. Whatever helps and does not hinder.
The larger the group the more necessary to introduce this early.


I had a huge argument about this. Some of the programmers wanted to
"express their freedom". After attempting to come to a "consensus" we
realised it was just getting silly : we instigated the rules against
the wishes of some of the older (more stuck in the wood) hands and the
proceeded to see nothing but better results. The code was regularly
reviewed, multistatement per line code removed, and guess what? The
programmers could move between modules with *ease* : in days before
people dreaded using "X"'s code because he used crap variable names,
insisted on breaking things down to a painfule level and basically not
use the strengths of the language. A few code reviews, standard
variable naming and standard ways of laying out loops and the issue
was gone. Underestimate something even as simple as the way you use
opening and closing braces : me, I'm a K&R man in that respect.

Cheers
Michael

cheers,

--
Debuggers : you know it makes sense.
http://heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Debug.html#tth_sEc
.



Relevant Pages

  • Re: (Prolog + LISP + Erlang) with integration issues versus C++
    ... >> they will write idiomatic lisp so soon after learning it. ... >> Learning the language on the job is not a recipe for good maintainance. ... > programmers. ... standard, but it's been extended so heavily it may as well not be. ...
    (comp.lang.lisp)
  • Re: Is C99 the final C? (some suggestions)
    ... >> because the ANSI standard obsoleted them, and everyone picked up the ANSI ... > fixed by using another language. ... programmers managing the meaning of the symbols for more generic operators. ... According to a paper by Intel, widening multiply accounts for something like ...
    (comp.lang.c)
  • Re: A petition to J3 apropos FORTRANs future
    ... At that time the standards committee was dominated by vendors, ... improving the fortran language in the 80's. ... during that time too if programmers had been in control of the ... F90 was an international ISO standard *BEFORE* it was a US ...
    (comp.lang.fortran)
  • Re: The wonder about .NET supporting or not C++ is about to turn to certainty.
    ... > Responding to some of the argument: ... So far I knew only one "class", the standard C++.... ... Windows forms CAN be used from any .NET language. ... > enough about the language to avoid the minefields (and most programmers ...
    (microsoft.public.vc.language)