472,371 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

Your word on notation?

I have been told not to use preceding underscores when notating data
members for example. What kind of notation do you use in general? I have
seen Microsoft uses hungarian notation a lot. Is that the most common one?
I also recognized that the more abstract a language becomes, the less
people care about proper notation (i.e. I haven't seen any C# or Java
code using anything even close to hungarian notation).
I have even recognized this behavior for myself. The less C-like C++
code I write, the less I care about notating it. For example, I found
that notating pointers with a preceding p helped a LOT not to confuse it
with anything else but being just a pointer.
In my more recent code I have to look really hard to find any pointers
at all, so I don't care about it anymore. Same for strings.

Do you use any specific notation at all?

--
Regards,
Matthias
Jul 23 '05 #1
4 1373
Matthias wrote:
I have been told not to use preceding underscores when notating data
members for example. [...]
Leading underscores can mean you're using a reserved identifier and
I, for example, try not to tempt my compiler.
Do you use any specific notation at all?


Some old habits die hard and I still use 'p' prefix for pointers and
'n' for counters. When I get to write from scratch I try not to use
leading underscores. They just make everything less readable for me.
At this point in my career I maintain a lot of somebody else's code,
so I try to use their notation to keep the code consistent unless it
is inconsistent to begin with in which case I try to make the least
amount of changes to bring it to a consistent state.

Don't get hung up on style unless your boss tells you to. Pick one
and follow it. Consistency is more important than any particular way
of naming your objects.

V
Jul 23 '05 #2
"Matthias" <no****@digitalraid.com> wrote in message
news:cu*************@news.t-online.com...
I have been told not to use preceding underscores when notating data
members for example.
IMO that's good advice. In many contexts (but not the
one you cite), names beginning with an underscore are
reserved to the implementation. Rather than try to remember
these rules, I also advise avoiding use of leading underscores
altogether. Or perhaps whoever told you the above was simply
dictating 'shop rules'.
What kind of notation do you use in general?
I try to use names which strike a balance between
descriptiveness and conciseness.
I have
seen Microsoft uses hungarian notation a lot.
Yes, their code is full of it. :-)
Is that the most common one?
Not for all C++ code in general, I doubt it.
I also recognized that the more abstract a language becomes, the less
people care about proper notation
The only 'proper' part of notation C++ cares about is correct
syntax. Subject to a few rules about reserved names, it
doesn't care what you name your identifiers. But again,
I recommend being descriptive. One reason I dislike
HN is that it unnecessarily binds a name to a type.
E.g. if I create an object of one type (e.g. 'int') and
give it some prefix to indicate 'int', and later I need
to change the type (to e.g. 'long'), I must remember
to change the prefix (and grep all the code where it's
referenced). A maintenance nightmare.

(i.e. I haven't seen any C# or Java
code using anything even close to hungarian notation).
Notation (as you're describing it) has nothing to do
with which language you use, except that the languages
rules about e.g. reserved names, etc. must be observed.
I have even recognized this behavior for myself. The less C-like C++
code I write, the less I care about notating it.
IMO one should simply care about making the code readable
and maintainable (to and by others, not only the author).
For example, I found
that notating pointers with a preceding p helped a LOT not to confuse it
with anything else but being just a pointer.
That's one case where I'm ambivalent about such a prefix.
(Since 'p' indicating 'pointer' is more generic that indicating
a specific type). However, I don't use this prefix either
(but I'll often name a 'temporary' pointer object as simply
'p' in a simple routine).
In my more recent code I have to look really hard to find any pointers
at all,
A pointer is easily recognized by reading its declaration (because
of the asterisk).
so I don't care about it anymore.
I don't know if this is the case for you, but I see many
folks using pointers in C++ where they're not necessary,
where a better, simpler solution exists.
Same for strings.
What do you mean? I don't see any need to indicate in an
identifer that an object has a string type. I just name
it what it means, e.g.:

std::string customer_name; /* imo the identifer makes it obvious
that 'customer_name is a string */


Do you use any specific notation at all?


Yes. Descriptive.

-Mike
Jul 23 '05 #3
Mike Wahler wrote:
"Matthias" <no****@digitalraid.com> wrote in message
news:cu*************@news.t-online.com...
[...]
In my more recent code I have to look really hard to find any pointers
at all,

A pointer is easily recognized by reading its declaration (because
of the asterisk).


Notations exist not to aid reading declarations. They exist to aid
reading and understanding code while declarations are not in the view.
Often those declarations are in the header, especially when members
are concerned.
[...]

Jul 23 '05 #4

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:yq*******************@newsread1.mlpsca01.us.t o.verio.net...
Mike Wahler wrote:
"Matthias" <no****@digitalraid.com> wrote in message
news:cu*************@news.t-online.com...
[...]
In my more recent code I have to look really hard to find any pointers
at all,

A pointer is easily recognized by reading its declaration (because
of the asterisk).


Notations exist not to aid reading declarations. They exist to aid
reading and understanding code while declarations are not in the view.
Often those declarations are in the header, especially when members
are concerned.


Yes, you're right, I suppose I misunderstood the context
of the question.

But I still feel that pointers aren't really hard to spot
because context usually indicates that they're pointers.
Of course I'm saying this from a perspecitive of reading
a particular piece of code for meaning, not arbitrarily
scanning code, looking for 'where are the pointers'.

Finally, I'm sure you'll agree that there will never be
a consensus on what is the 'best' notation.

-Mike
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fazer | last post by:
Here comes another small question from me :-) I am curious as to how I should approach this issue. I would just want to parse simple text and maybe perhaps tables in the future. Would I have to...
3
by: Robert Mark Bram | last post by:
Howdy All! Is there any difference between referencing objects and attributes with dot notation or bracket notation? Example, document.formname.controlname document Can I access...
2
by: David | last post by:
After getting some help working through my bugs, I have what seems to be a robust, working word counter script. I post it here to benefit others that might want this in the future and so that if I...
7
by: Philipp Lenssen | last post by:
I would like to know what others do to prevent line-breaks, using &nbsp; For example, the guidelines for the company have certain words (like "Model XY", where "Model" and "XY" shouldn't be...
2
by: funcSter | last post by:
I was asked to program using the Dutch Notation with C#. I am not familiar with the Dutch notation at all. I use the Hungarian. I asked a programmer friend "What is the Dutch Notation?" He...
7
by: onetitfemme | last post by:
Hi, for some reason Firefox is apparently inserting a new line somehow after some IPA symbols which I have written in their hexadecimal notation. Also, I would like to have two spaces by...
4
by: Gregory Edigaroff | last post by:
Hello, Everybody! Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest, so I believe somebody have a solution for it. I need either a full...
22
by: bearophileHUGS | last post by:
>From this interesting blog entry by Lawrence Oluyede: http://www.oluyede.org/blog/2006/07/05/europython-day-2/ and the Py3.0 PEPs, I think the people working on Py3.0 are doing a good job, I am...
3
by: gcmartijn | last post by:
Why is this not working ? bla = 'hondenriem' print bla # correct ! (= hond) print bla # nothing ! (= en) print bla # nothing ! (= riem) Why don't bla and bla won't work ? I use this...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.