Talk:Enum
From APIDesign
(Difference between revisions)
194.3.183.35 (Talk)
(Comment provided by stephane.appercel@neuf.fr - via ArticleComments extension)
Next diff →
Revision as of 15:05, 13 January 2011
Comments on Enum <comments />
As you mentioned it, the decision to define a finite set of module categories was not correct, as it would have been possible to foresee the needs for custom module categories.
However, there is a one simple solution for this kind of problems. First, define a ModuleCategory interface, with some operations to get the properties of a module category. Second, define an enum called StandardModuleCategory, which implements this interface and define the standard module categories. Finally, define a class called CustomModuleCategory that also implements this interface. And use the interface everywhere in your code. You can also create an utility class called ModuleCategoryProvider with a single method named lookupByName(), or have a complete ModuleCategoryRepository.
--stephane.appercel@neuf.fr 16:05, 13 January 2011 (CET)