Showing posts with label composite pattern. Show all posts
Showing posts with label composite pattern. Show all posts

2011-07-01

Scala Enums: Real Life Example

I wanted to follow up my previous post on Scala Enums with a real-life example. The beauty of this example is my ability to use advanced typing techniques such as type parameters, mixin traits, even a composite pattern, in what basically amounts to a simple enumeration type. This code is quite easy to read, and perfectly conveys my intentions. I don't even want to imagine what I would have done in Java for something like this.