I have a design problem where the requirement is something like this :
- Write a generate function that takes a parameter("TYPE")
- Depending on the TYPE, I need to generate a String and return it. So TYPE effectively changes the way you generate the String.
I am deliberating between two design options :
- Using enum : Create a enum having the TYPES. Then provide a generate method that depending on TYPE does the processing and returns a string.
- Using Interface : Create an interface having a function generate(). Create implementations for each TYPE, to implement the generate().
Which do you feel is better and for what reasons.
Aucun commentaire:
Enregistrer un commentaire