Revised implementation of Strategy Pattern in Java

How Java 8 killed the Strategy Pattern

Image by mcdonaldland.info

By introducing lambda expression in Java 8, many things have changed in Java world and now Java developers can write more concise code and also use functional patterns much easier.

I read a nice article about “How Scala killed the Strategy Pattern” by Alvin Alexander that compares an old Java implementation of Strategy Pattern by Wikipedia with more concise Scala implementation, but that implementation used old Java syntax (prior Java 8) and was very verbose:

Strategy Pattern (prior Java 8)

and Scala implementation of the Strategy Pattern:

Strategy Pattern (Scala)

It isn't a fair comparison because after introducing lambda experession in Java 8, we can reimplement the Strategy Pattern in Java like this:

Strategy Pattern (Java 8)