How to handle data

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?

  1. parse the string into an int, set individual flags in an object that could be checked later with CanExport(), IsAdmin(), etc.
  2. parse the string into an int, write bit checks into those same methods
  3. write an accessor for the whole int value and check each bitflag every time you need to
  4. 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.

This entry was posted in tech. Bookmark the permalink.

One Response to How to handle data

  1. Danny Howard says:

    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?

    “Shoot the hostage.”

    Duh.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>