class Thread
{
public:
Thread(unsigned long flags);
~Thread();
private:
HANDLE _thread;
DWORD _threadid;
};
Personally, I find it quite effective and pleasant to use. I''ve found myself switching over from the well used ''m''-underscore (''m_'') convention to just the underscore (_).
So what do you guys think of this?
Dire Wolf
direwolf@digitalfiends.com
P.S. Before anyone replies that a variable starting with an underscore is invalid, just let me say that you''d be wrong.
Does anyone use the underscore for...
Recently while perusing through, "Design Patterns", I took notice of an interesting naming convention. The authours used the underscore character to represent the member variables of a class.
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
www.digitalfiends.com
December 13, 2000 12:25 PM
I think it is inconvinient, cause many C functions in standard libraries begins with underscore, and it is bad for public members, cause reference like object._publicmember looks not very good. Thank you.
Novoselov Ilya
nullpointer@chat.ru
Novoselov Ilya
nullpointer@chat.ru
Actually, if you follow Design Patterns correctly, and stick to strict Object Oriented principles, then there is no such thing as a public member.
People might not remember what you said, or what you did, but they will always remember how you made them feel.
Mad Keith the V.
People might not remember what you said, or what you did, but they will always remember how you made them feel.
Mad Keith the V.
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Anonymous,
Its very rare to have public data members. Still, to address your point:
and
Look fine to me. As Mad said, you shouldn''t really be using public data members in user classes. Private implementation classes with public data members are acceptable in some circumstances but in general are not conducive to proper program design.
Just my opinion.
I''d still like to hear some more opinions on the matter.
Dire Wolf
direwolf@digitalfiends.com
Its very rare to have public data members. Still, to address your point:
object._whatever
and
object.m_whatever
Look fine to me. As Mad said, you shouldn''t really be using public data members in user classes. Private implementation classes with public data members are acceptable in some circumstances but in general are not conducive to proper program design.
Just my opinion.
I''d still like to hear some more opinions on the matter.
Dire Wolf
direwolf@digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
www.digitalfiends.com
I think as long as a convention does not make the code harder to read or maintain then it is plenty fine if it helps to keep track of things.
Corry Trout
ctrout@telusplanet.net
Corry Trout
ctrout@telusplanet.net
I thought prefixing variables/functions with _ would invade the compiler''s namespace?
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Well that is your opinion and you are entitled to it
NuffSaid,
The underscore does not invade the compiler''s ''namespace''. Microsoft defines the double-underscore as ''reserved'' by the compiler. They recommend that you do not use the underscore character for variable names due to future implementations. This is probably to avoid clashes with reserved words like __stdcall etc.
I''m still debating what I like better:
or
NuffSaid,
The underscore does not invade the compiler''s ''namespace''. Microsoft defines the double-underscore as ''reserved'' by the compiler. They recommend that you do not use the underscore character for variable names due to future implementations. This is probably to avoid clashes with reserved words like __stdcall etc.
I''m still debating what I like better:
class Thread{ public: Thread(); ~Thread(); private: HANDLE _threadid;};
or
class Thread{ public: Thread(); ~Thread(); private: HANDLE m_threadid;};
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
www.digitalfiends.com
quote:
P.S. Before anyone replies that a variable starting with an underscore is invalid, just let me say that you''d be wrong.
Well they wouldn''t be totally wrong. Any name, variable or not, starting with an underscore followed by a capital letter or with two consecutive underscores anywhere in the name is invalid i.e. reserved for the implementer (e.g. Microsoft) and the standard.
quote:
This is probably to avoid clashes with reserved words like __stdcall etc
That''s exactly the reason, which is why the new types in C99 have names like _Bool instead of ''bool''
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement