Enums vs. HashMap vs. others for decision handling
Joined: Dec 02, 2010
In my project I have encountered a situation where given an input functionality varies.
So I have though of two ways for dealing with this situation. Both work but want to choose one.
Using a Enum where given an input and depending on enum output I will handle the business login. Also I have handled the exception saying if there is no enum for that particular type I will return null.
Using HashMap which gives the value when given a key. And using that value will build the business logic.
There are even many ways like using if-else, switch-case etc.
Can someone help me in choosing why I should go with a particular implementation.
My team lead says hashmaps because of performance but there will not be more than 5 types.
I prefer enums because of the readability.
So thats where I am thinking, what to go with. Any suggestions??