Steve McConnell Quote
Don't use a boolean variable as a status variable. Use an enumerated type instead. It's common to add a new state to a status variable, and adding a new type to an enumerated type requires a mere recompilation rather than a major revision of every line of code that checks the variable. Use access routines rather than checking the variable directly. By checking the access routine rather than the variable, you allow for the possibility of more sophisticated state detection. For example, if you wanted to check combinations of an error-state variable and a current-function-state variable, it would be easy to do if the test were hidden in a routine and hard to do if it were a complicated test hard-coded throughout the program.
Steve McConnell
Don't use a boolean variable as a status variable. Use an enumerated type instead. It's common to add a new state to a status variable, and adding a new type to an enumerated type requires a mere recompilation rather than a major revision of every line of code that checks the variable. Use access routines rather than checking the variable directly. By checking the access routine rather than the variable, you allow for the possibility of more sophisticated state detection. For example, if you wanted to check combinations of an error-state variable and a current-function-state variable, it would be easy to do if the test were hidden in a routine and hard to do if it were a complicated test hard-coded throughout the program.
Related Quotes
For everything in this journey of life we are on, there is a right wing and a left wing: for the wing of love there is anger; for the wing of destiny there is fear; for the wing of pain there is heali...
C. JoyBell C.
Tags:
ancient, flight, flying, human race, humanity, imperfection, inspirational, inspirational life, inspiring, journey
It was uncontrollable, overpowered by others, these colors within me, staring out at a black and white world; without spurning about, wanting to rule, too much negligence, they left me no choice, but...
Anthony Liccione
Tags:
black and white, bring to life, broken, color, colorless, dye, life, lightning, negligence, overpower
About Steve McConnell
Steven C. McConnell is an author of software engineering textbooks such as Code Complete, Rapid Development, and Software Estimation. He is cited as an expert in software engineering and project management.