Java enum as a strategy pattern

less than 1 minute read

I’ve always thought that Java enums can represent a simple but powerful strategy pattern baked into Java.

This idea has been reinforced by this article by Ralph Johnson of GoF fame, where while talking about design patterns and language design he says:

Design patterns are not made of stone. […] Over time, we should change our programming languages so that they build in things that used to be patterns.

This evolution of modern languages will (hopefully) increase the number of people that are really able to write Object Oriented code, modelling behaviours and not only using objects as a dull namespace construct.