Maybe you’ve noted the new poll in the sidebar. I’ll replicate the question here for your perusal.
Ok, let’s say you logged into a web service via XML, and one of the responses back was an integer for a bitfield indicating possible permissions. What would you do?
- parse the string into an int, set individual flags in an object that could be checked later with CanExport(), IsAdmin(), etc.
- parse the string into an int, write bit checks into those same methods
- write an accessor for the whole int value and check each bitflag every time you need to
- write an accessor for the string value, reparse it into an int every time you check the access flag, and then use % to check for bitflags instead of &
Your challenge, if you choose to accept it, is to top that.