Sign in to follow this  
  • entries
    557
  • comments
    1237
  • views
    421072

True, False, FileNotFound

Sign in to follow this  
Evil Steve

2128 views

Sigh. From the SDK of a certain big-name console:

enum GraphicsBoolean

Graphics's version of bool-type values.

Enumerator:
GRAPHICS_FALSE
GRAPHICS_TRUE
GRAPHICS_DISABLE
GRAPHICS_ENABLE


That makes me sad.

EDIT: Censored the library name
Sign in to follow this  


3 Comments


Recommended Comments

this is all too common. When the enum starts out its just a replacement for the lack of a boolean data type in C, and its used as a return code; true for success and false for error, but then what always seems to happen is that more error codes are needed; file not found, and so on. THe only real mistake is calling the enum Boolean rather than ErrorCode.

To avoid this, always call your true-for-ok/false-for-error enums something like ErrorType and use NO_ERROR or similar. Problem solved.

Share this comment


Link to comment
It's worse than that. It's the equivilent of YES, NO, TRUE, FALSE. So now you have to test for multiple values (did it return YES or TRUE?). And given that you most likely wrote or are using documentation that existed before GRAPHICS_DISABLE and GRAPHICS_ENABLE were added, you won't check for those. Not only that, but who checks for "other" in what is supposed to be a boolean test?

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now