Phillip Lord writes:
 > >>>>> "Paul" == Paul Landes <[EMAIL PROTECTED]> writes:
 > 
 >   Paul> Here is something I needed wrote this weekend.  What this
 >   Paul> provides is:
 > 
 >   Paul> Templates:
 >   Paul> - jde-gen-enum: an `enumeration' class, which is a static
 >   Paul>   collection of identifiers much like C `enums' but object
 >   Paul>   oriented.  The generated class is optimized for
 >   Paul>   serialization and used as keys.
 > 
 > 
 > 
 > It's possible to do this using a super class. I use the class
 > following.

This is one approach.  Both have their advantages and
disadvantages.  It might be a bad idea to use inheritance
for immutable instances because now your sharing
implementation details across classes.  You can give your
super class some unique identifier, but as you add more
things (i.e. description, identifiers, sub enums, etc.) you
now have to consider these changes in overriden
java.lang.Object methods like equal() and hashCode() for
both performance and maintenance reasons.

I like the template approach because this gives me a
template to work with, then I can specialize it for what I
need.

 > I also wonder whether its worth doing this when Java is getting
 > language support for Enums in 1.5....

Perhaps not.  There are many of us that are still on, and
will be stuck on 1.4, for a while.  I my situation, we have
to pick and commit to a J2EE application server.  J2EE
vendors tend to be slow to upgrade Java versions.


Thanks for your example and your input, Phillip.



[ Enumeration code snipped -pl ]

-- 
Paul Landes
[EMAIL PROTECTED]

Reply via email to