Jump to content
  • Advertisement
Sign in to follow this  
Yohomyth

C++ servey type thingy

This topic is 4836 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 just wanted to know what kind of type names and class names and all of the fun stuff people here prefer. functions my_func myfunc myFunc MyFunc variables my_var myvar myVar MyVar nMyVar standard types MYTYPE mytype_t myType_t MyType_t MyType unions UMyUnion MyUnion myunion_u (typedef to myunion_t) myUnion_u (typedef to myUnion_t) MyUnion_u (typedef to MyUnion_t) enumerators EMyEnum MyEnum myenum_e (typedef to myenum_t) myEnum_e (typedef to myEnum_t) MyEnum_e (typedef to MyEnum_t) structs MYSTRUCT mystruct_s (typedef to mystruct_t) myStruct_s (typedef to myStruct_t) MyStruct_s (typedef to MyStruct_t) MyStruct SMyStruct struct member variables m_myvar myvar_ myvar classes CMyClass MyClass abstract base classes MyInterface CMyInterface IMyInterface class member variables m_myvar myvar_ myvar class static variables s_myvar myvar_ _myvar myvar global/external variables g_myvar _myvar myvar enum vals/flags MYDEFINE PREFIX_MY_DEFINE PREFIX_MYDEFINE common constants MYDEFINE mydefine macros MYDEFINE MY_DEFINE templates TMyTemp mytemp MyTemp namespaces mynamespace MyNamespace NMyNamespace plz let me know if i'm forgetting something. [Edited by - Yohomyth on August 17, 2005 9:27:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
This is just my personal opinion (so please no idiotic response from anyone, its just a meaningless personal opinion):

All uppercase letters for type names are an abomination.
Hardcore Hungarian notation is also an abomination and almost completely pointless in modern IDEs.

I've come to relize that trying to use different name conventions than the one a language uses (or its standard library uses) looks ugly. For instance i use to use camel notation in C++ but it looks completely out of place when using C++ standard library components as they don't. So i changed all my code to a style very similar to (may aswell be the same as) the C++ standard library (as does boost library) uses and now code looks more cohesive, yada, yada.

[Edited by - snk_kid on August 17, 2005 7:07:23 PM]

Share this post


Link to post
Share on other sites
Fundamental types:
int, short, etc... or int8_t, int16_t using the C99 stdint.h notation.

Typedefs:
typically foo_t or foo_type depending on the usage.

Class names:
TitleCase

Function names:
lowercase_with_underscores()

Variable names
this_is_a_variable;

Member variables:
with_a_trailining_underscore_

Globals:
Happens rarely enough - I don't know

Struct:
structs are classes

Share this post


Link to post
Share on other sites
Types (Enums, classes, typedefs): LikeThis

Abstract base classes: ILikeThis

Functions and variables: like_this

Private member variables: like_this_

Preprocessor defines and enumeration values: LIKE_THIS

Share this post


Link to post
Share on other sites
Classes, structs, enums, typedefs: FooBar
Enumerants: FOOBAR_BAZ
Functions: FooBar
Macros: FOO_BAR
Variables: fooBar
Member Variables: m_fooBar
Global Variables: Don't know, I haven't used them in a while

Share this post


Link to post
Share on other sites
Interfaces (abstract base classes): ITitle
Classes: CTitle
Structs: STitle
Template arguments: TTitle
Functions: Title
Enums: ENUMABBRV_TITLE
Macros: TITLE
Variables: mTitle, gTitle, title and longerTitle (locals/parameters)

I personally see tagging the variable type to the name (nTitle, m_fTitle) to be redundant.

EDIT: Anyone shove external library includes into a namespace to avoid name clashes? ie. namespace Win32 { #include <windows.h> }

Share this post


Link to post
Share on other sites
I forgot to include why I posted this thread. I'm working on a library called RosClsLib, which will mostly be used for reading files of all kinds of formats, but can be used for other things like windowing and consoles. EDIT: and I want people other than me to pick the coding format for this. EDIT again: And I have headers to include stuff from Kernel32.DLL and User32.DLL and stuff so you won't have to #include <windows.h> or really anything other than "rcl.h".

[Edited by - Yohomyth on August 17, 2005 9:13:03 PM]

Share this post


Link to post
Share on other sites
standard types
MyType

enumerators
MyEnum

structs
MyStruct

struct member variables
my_var

classes
MyClass

abstract base classes
MyInterface

class member variables
my_var

class static variables
my_var

functions
myFunc

variables
myVar

global/external variables
myvar

enum vals/flags/common constants
PREFIX_MY_DEFINE

macros

MY_DEFINE

templates
MyTemp

namespaces

mynamespace


Share this post


Link to post
Share on other sites
here's what i prefer:

functions: MyFunc
variables: myVar
standard types: mytype_t
enumerators: myEnum_e (typedef to myEnum_t)
unions: myUnion_u (typedef to myUnion_t)
structs: myStruct_s (typedef to myStruct_t)
struct member variables: myVar
classes: CMyClass
abstract base classes: IMyInterface
class member variables: m_myVar
class static variables: s_myVar
global/external variables: g_myVar
enum vals/flags: PREFIX_MYDEFINE
common constants: MYDEFINE
macros: MY_DEFINE
templates: TMyTemp
namespaces: MyNamespace

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!