Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Cybertron

C++ notation and naming conventions

This topic is 5897 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a new graphics interface right now using OOP, and was wondering what are the standard naming conventions for classes, variables, functions and enums I already use hungarian notation for variable names (except for ''m_'' or ''g_'') but classes are all over the place and functions are usually just describe what they do In need your input on a logical way to orginize all these data types and structures

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Cybertron
I am working on a new graphics interface right now using OOP,
<snip>
I already use hungarian notation for variable names


Some people are going to tell you that HN is redundant in an OO world.




"I would defend the liberty of concenting adult creationists to practice whatever intellectual perversions they like in the privacy of their own homes; but it is also necessary to protect the young and innocent."
Arthur C Clarke

Share this post


Link to post
Share on other sites
quote:
Original post by Magmai Kai Holmlor
Standards are great! There''s so many to choose from!


Haha! Too true, too true.

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/

Share this post


Link to post
Share on other sites
The only "notation" I use are to indicate scopes and
to distinguish pointers from other types.

g_ : global variable (ewww!)
m_ : member variable (very nice)
s_ : static variable (...)
p : pointer variable (MUST!)

That''s all! I need to distinguish pointers from the others
because pointers use -> rather than . to access members.
References are fine in that regard.



Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
Here''s my notation:
(local) variables:-- item, itemIndex, itemStr (not strItem, yuk!)
member variables:-- item_, itemIndex_, itemStr_
global variable:-- theItem, theItemIndex, theItemStr
pointer:-- pItem, pItemIndex, pItemStr
pointer global:-- pTheItem, pTheItemIndex, pTheItemStr

(member) functions:-- EatItem(), Eat()
#define/const int:-- MAX_ITEM, MAX_SIZE, LOG()
classes/structs:-- Star, Rectangle, Object, Alien, SuperAlien
template <class X>:-- where X = T, U ,V ,W... or A (for allocator )
quote:
Quote from tangentz
p : pointer variable (MUST!)


YES, IS A MUST!!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I put caps on things that there are one of, and go lower case with underscores for members.

Class
GlobalVariableOrFunction
StaticVariableOrFunction

member_variable_or_function
local_variable_in_a_function

so if you see C::D you know it is static whereas C::d is just a plain member. Likewise if you see V you know it is a global variable or function and if you see v it is a local variable of function

Share this post


Link to post
Share on other sites
Thanks for the input

It looks like naming scope of the variable is a good idea. local variables can be left alone but classes can have all their variables prefixed with m_.

What should I call classes? I either start it with C or ends in "Class". Interfaces usually start with I_ (like I_GraphicsInterface). What could I call the implementation of that interface?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!