R
Roedy Green
Something about enums and I really click.
I'm finding the enum pattern really helps chaotic code that deals with
doing different things in different situations. If I can come up with
some sort of enum to classify the situations, the code becomes
somewhat bulkier, but it is so simple to understand and extend. It
helps clarify for ME just how it all works.
If you have a number of legal and illegal combinations of things, you
can use the enum constructors to describe a set of legal combinations,
then just search the enums to see if your pattern matches or the one
with the best fit.
It then becomes trivial to proofread the list. It is easy to add
methods to each combination to override the usual case. And of course
adding or removing a legal combination becomes a snap, rather than
pruning logic in a dozen places.
The main thing that annoys me with them is, because the enum constants
are implemented as anonymous inner classes, they cannot contain static
variables or methods private to them. Further their constructors
cannot access any statics.
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
I'm finding the enum pattern really helps chaotic code that deals with
doing different things in different situations. If I can come up with
some sort of enum to classify the situations, the code becomes
somewhat bulkier, but it is so simple to understand and extend. It
helps clarify for ME just how it all works.
If you have a number of legal and illegal combinations of things, you
can use the enum constructors to describe a set of legal combinations,
then just search the enums to see if your pattern matches or the one
with the best fit.
It then becomes trivial to proofread the list. It is easy to add
methods to each combination to override the usual case. And of course
adding or removing a legal combination becomes a snap, rather than
pruning logic in a dozen places.
The main thing that annoys me with them is, because the enum constants
are implemented as anonymous inner classes, they cannot contain static
variables or methods private to them. Further their constructors
cannot access any statics.
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes