Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/22/01 10:49
Read: times


 
#14327 - RE: use of flag
You can use this flag named "My_Flag" in the code.

In my opinion, naming flags such as "xxx_Flag" is often unhelpful; eg,
some people like to name their flags like "Door_Flag" - then have code like
if( Door_Flag )
{
   // Do stuff for Door_Flag set
}
else
{
   // Do stuff for Door_Flag clear
}
But it's not obvious what "Door_Flag set" actually means!

Therefore I prefer to name flags so that they directly show their meaning; eg,
if( Door_Is_Open )
{
   // Do stuff for open door
}
else
{
   // Do stuff for closed door
}

This is, of course, subjective & a matter of style but I think it improves the "readability" (and hence maintainability) of your code.
I speak as one who has had to wade through plenty of code with poorly-named (or even misleadingly-named) variables...!



List of 17 messages in thread
TopicAuthorDate
use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag            01/01/70 00:00      
RE: use of flag, Babar            01/01/70 00:00      
RE: use of flag, Babar            01/01/70 00:00      
RE: use of flag, Phillip            01/01/70 00:00      
RE: use of flag, Phillip            01/01/70 00:00      
RE: use of flag, Phillip            01/01/70 00:00      

Back to Subject List