Re: masks and enums
On Jul 31, 4:50 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
On Mon, 30 Jul 2007 21:23:35 -0400, Lew <l...@lewscanon.nospam> wrote,
quoted or indirectly quoted someone who said :
Right, good point. But the question still stands as to why they must be
nested, or when it might be better.
You might nest them if they are used by only the enclosing class. I
find though the enums tend to be popular and reused elsewhere, so I
tend to put them in a separate public or default class in their own
file.
Also too, I tend now to put more and more logic in the enums, and less
in the classes that use them. It makes sense then to give them their
own file to grow in.
I tend to do this too. If there is behavior the should be executed
based on the enum value, I add it to the enum itself, and then just
call myEnumValue.foo(); :-)
Who'd have thought that enums and polymorphism could be mixed. As
well as being singletons.
But the main reason is I can find them more easily then they are in
their own file.
--
Roedy Green Canadian Mind Products
The Java Glossaryhttp://mindprod.com