0

Since a little console programming I'm realy considered writing good readable code. I often see code, where the attributs are named by there type or their storage location. for example

matrix g_mView; // global_matrixView
bool m_bToggleLight; // member_boolToggleLight

What do you think how variables should be named, to make it easy for everbody? f.e. how to name a local / global variable? how to name Vector3, Vector2 variables?

Jinxi
  • 303
  • 1
  • 13
  • Your question is unanswerable (every company may have its own naming conventions). You may look at http://msdn.microsoft.com/en-us/library/ms229045.aspx though (for your own projects). These rules describes naming convention very widely used on the Internet. – Spook Jun 19 '13 at 10:18
  • Using `m_` to indicate membership for example is considered bad practice today. Generally Hungarian notation (used throughout old Win32) is also bad practice (like hWnd for a HANDLE to Window). – bash.d Jun 19 '13 at 10:19
  • 1
    This might be useful http://stackoverflow.com/questions/841888/picking-good-identifier-names/853187#853187 – Dr_Sam Jun 19 '13 at 10:19
  • Coding style is something you have to work with whatever the organisation that you work with stipulate. If you don't work, then come up with something that you like. Everyone has their idea of how to do this. – Mats Petersson Jun 19 '13 at 10:19
  • have a look at this http://stackoverflow.com/questions/234866/variable-naming-conventions-in-c – Rohan Jun 19 '13 at 10:20
  • many thanks for the links! seems to be a never ending story this naming convention... – Jinxi Jun 19 '13 at 10:52

1 Answers1

1

First rule is to be consistitent. Second rule I'd advice - is to use a commonly used coding standards that suits your need. For instance, you can use google's standards: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

omer schleifer
  • 3,897
  • 5
  • 31
  • 42