Jump to content
  • Advertisement

Archived

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

Metal Typhoon

Formats of coding !

This topic is 5474 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

Well. i was wondering what format you guys use for the following , this is what i use : Classe name : C + Name - CCore Classe func : Engine init in l.c + Func name - cbStartEngine Classe vari : Engine init in l.c + var name - cbMouseX Struct name : Engine init in u.c + name - CBIMAGE Struct vari : Engine init in l.c + var name - cbData enum : Engine init in u.p + name - CBPARAMS function params : all in lower case - .. (int x,int y) var inside functions : all in lower case - bits #infndef : _ + Class name in u.c + _ + H + _ - _CCORE_H_ if i''m missing something please tell me :D thx , and i''m waiting to see some replies
Metal Typhoon

Share this post


Link to post
Share on other sites
Advertisement
I personally prefer _C prepended to my classes and _S prepended to my structs. Also, I do''t do anything special with class member''s/functions, i just leave them as is. I don''t always make function params all lower case, for example, (int xPos, int yPos).

Nothing wrong with your format, as long as it''s easy enough to read.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Please do a search for coding style, or just style, or code formatting. There has been plenty of discussion about style and there isn''t any specific style. It''s what you prefer.

Try asking more focused questions if you want real answers that will help you out.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Classe name : Capatalized with _ between words : ex Test_Class
Classe func : lower case with _ between words : small_func
Classe vari : lower case with m_ prefeix and _p for ptr, : ex m_p_test ( test is a pointer )
Struct name : Same as Classes
Struct vari : Samve as Classes func
enum : All upper case : TEST_ENUM
function params : all lower case as well

local clases, structs, and enum defined within a class : prepend the _ : ex _Sub_Class, _SUB_ENUM

-ddn

Share this post


Link to post
Share on other sites
quote:
Original post by Beer Hunter
Names beginning with underscores are reserved for the implementation.
I am the implementor of my own classes! I prefix private memebers with underscore, and nobody, and I repeat NOBODY!, can stop me! MUAHAHAHA... /runs into wall

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
> do you think it''s easy to read ?
hard to tell.. post some code and i''ll try to judge it fairly

Share this post


Link to post
Share on other sites
I think just about all class, struct, enum, identifiers and local and global variables I capitalize the first letter of each word in the identifier name (ex: SomeVariable, SomeClass, SomeStruct, etc). Then I prepend some small descriptor to the identifier name, as follows:

Interface classes - prepend an I (ex: IRenderer)
Concrete classes - prepend a C (CDirectDrawRenderer)

Following pertains to members of classes:
Boolean variable - prepend a m_b (ex: bool m_bFavorVRAM)
Numerical (int/float/double) variable - prepend a m_n (ex: int m_nWidth)
Pointer variable - prepend a m_p (ex: LPDIRECTDRAWSURFACE7 m_pBackBuffer)
Variable that does not fall under one of the above categories - prepend a m_ (ex: SurfaceProps m_SurfaceProps)

In the next batch, I refer to local as either declared in local scope, or a function parameter:
Local boolean variable - prepend a b (ex: bool bSuccess)
Local numerical variable - prepend a n (ex: int nNumBytes)
Local pointer variable - prepend a p (ex: unsigned char* pBuffer)
Local variable that does not fall under one of the above categories - prepend nothing (ex: DDPIXELFORMAT SurfacePixelFormat)

Pertains to global variables:
Boolean variable - prepend a g_b (ex: bool g_bMinimized)
Numerical (int/float/double) variable - prepend a g_n (ex: int g_nSomeRandomCounter)
Pointer variable - prepend a g_p (ex: IRenderer* g_pRenderer)
Variable that does not fall under one of the above categories - prepend a g_ (ex: WindowProps g_WinProps)

Some special notes:
Macros and Constants - all capital letters, each word separated by an underscore (ex: const int SCREEN_WIDTH = 640)
Enumerations in an enum - all captial letters, each word separated by an underscore, the first word is the enum name (ex: enum PixelFormat { PIXELFORMAT_24BIT }; )


[edited by - MRom on December 12, 2003 10:58:51 PM]

Share this post


Link to post
Share on other sites
Hmm, just make sure its standard in all your code. Personaly,
i like to mush things together in an almost hungarian notation sort of deal. generaly it works like this.

Classes: MYLIBClass

for instance, if i was writing the back end of PuzzleMania, and i was doing a map class, it would be something like PMMap.

for boolean variables its always

ifImdead, ifThisistrue, ifWater, im sure you get the drift

numbers are

nMax, nSize, exc.

width and height are just w and h though.

Strings are sMyString, sThis, exc.

hmm.... i think thats about it. oh yea, floating point variables are always fudged for me, since i usualy only use it internaly in 3d things, so it doesent matter the consistancy.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!