Re: Help with Naming Conventions
"Daz" <cutenfuzzy@gmail.com> wrote in message
news:1148990514.838529.277060@y43g2000cwc.googlegroups.com...
Hi all!
This question may hopefully spark a little debate, but my problem is
this:
I am sure it's not just me who struggles to think up names for
variables. Obviously, thinking up a name 'can' be simple, but when you
are trying to create variable names that are easy to remember,
descriptive, and not more than say 15-20 characters long, I come a
cropper! Would anyone be able to give me any pointers as to how I can
create the variable names I am looking for, or is it simply a case of
having a notepad doc open and keeping track of what each name is?
Any comments would be appreciated.
Variable names are generally easier, as they only have to make sense in
context.
void ReadPlayerFile( const std::string& Filename )
My function names are generally a verb and a noun. A verb as to what I'm
going to be doing to the noun. I think that ReadPlayerFile is perfectly
descriptive and doesn't even neeed any commenting. Filename is fine,
because if I want to know what filename, I just look at the function name,
it's the PlayerFile name of course.
Iterators I've decided on going with "it" with a prefix as to what it's an
iterator for, keeping them short. This stems from the age old concensus to
name for loop variables i. So I use it for iterators. Here's a few
examples of functions and paramters I'm using in my current program:
void SendHealthToPlayer( const CPlayer& ThisPlayer )
bool CheckIfPlayersHit( map_key_pcmissile::iterator& mit )
EBodyParts ChracterHit( const CCharacter& Char, const JVEC3& BeamPos )
void CheckLimb( const int Value, const int Max, bool& Disabled, bool&
Destroyed )
void ReadMapData( const std::string FileName, CMapValues& MapValues );
void SendMessageToPlayer( const SOCKET Socket, const BYTE MessageType, const
std::string& Message );
void SendMessageToGMs( const BYTE MessageType, const std::string& Message );
void SendMessageToRange( const int Map, const JVEC3 Pos, const BYTE
MessageType, const std::string& Message, const float Range = 0 );
void SendMessageToMap( const int Map, const BYTE MessageType, const
std::string& Message );
void SendMessageToWorld( const BYTE MessageType, const std::string&
Message );
void SaveServerData()
CMap& FindMap( const unsigned int MapNumber )
CPlayer& FindPlayer( const SOCKET Socket )
CNPC& FindNPC( const unsigned int ID )
CPlayer& FindPlayer( const std::string Name )
std::string trim( const std::string& text, const char TrimChar = ' ' )
std::string SendIfLongToPlayer( const SOCKET Socket, const BYTE MessageType,
const std::string SendMessage, const unsigned int MaxLength = 70 )
std::string CreateCharMessage( const unsigned int Key, const CCharacter&
Character )