Re: global variables are bad?
- From: "Richard G. Riley" <rgrdev@xxxxxxxxx>
- Date: 12 Mar 2006 17:30:32 GMT
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
.
- References:
- global variables are bad?
- From: fabio
- Re: global variables are bad?
- From: Michael Mair
- Re: global variables are bad?
- From: Laurijssen
- Re: global variables are bad?
- From: Michael Mair
- Re: global variables are bad?
- From: Richard G. Riley
- Re: global variables are bad?
- From: Michael Mair
- Re: global variables are bad?
- From: Richard G. Riley
- Re: global variables are bad?
- From: Michael Mair
- global variables are bad?
- Prev by Date: Re: global variables are bad?
- Next by Date: Memory leak problem
- Previous by thread: Re: global variables are bad?
- Next by thread: Re: global variables are bad?
- Index(es):
Relevant Pages
|