Home > Development > Getting bitten by enums

Getting bitten by enums

One of the issues I have had to fix recently had me scratching my head, and promising myself be more careful when using enums in the future.

For the purposes of this example assume you have an employee class you may decide to store the gender an enum, it will restrict the choices the other developers have when creating or modifying an instance and provides intellisense. When you request an Employee object from your service layer you can then simply check the value of the enums to get the value.

In a nutshell the problem I had was that the information in the database was correct but was not setting the value of the enum. I spent a day of so working through the various layers of the application trying to find what was overwriting the value of the variable until I came to the realisation that the enum had in fact never been set.

    What this led to was the system working as expected for a majority of the time and catching us out in a big way. In smaller systems this may not be an issue but when you have lots of layers in your application (too many perhaps?) its worth checking.

    Categories: Development
    1. No comments yet.
    1. No trackbacks yet.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s

    %d bloggers like this: