Friday, September 24, 2010

Beautiful Java Enums

File under “It’s never too late to blog about Java 5 features” and “you wrote 1000 words on what?”.

Way back before Java 5 I fell in love with the Type Safe Enum pattern described in Martin Fowler’s Refactoring. You know the one, where an instance of a class has members of itself as public static fields. It was so clever (not always a compliment) and I applied it everywhere I could. Fowler’s example dealt with blood types... to read the full article surf over to http://canoo.com/blog/2010/09/24/beautiful-java-enums/


And don't forget to spread a little DZone love...

2 comments:

Jaroslav Tulach said...

I have nothing against the concept of enum and I used to be fine with the way it is implemented in Java. But during last month I have struggled with converting the finite set of enum values to infinite. I can confess this is much harder than it should be.

Next language designer incorporating enums should learn from Java mistakes and do a better job.

Galia Co Hagan said...

Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java EE Training in Chennai. or learn thru Java EE Training in Chennai Students.