Modern Interpreter Pattern in Java
A monumental milestone was the book Design Patterns: Elements of Reusable Object-Oriented Software, also known as the “Gang of Four” book, released in 1994. Both are products of their times, using 1990s languages and tools. It's now 2020's and we have seen some things. Java now uses lambdas and streams extensively. We now desire immutability. Java's garbage collection has vastly improved by leaps and bounds. So, while Java has undoubtedly changed, how about our design patterns? That's why we will discuss one of the patterns from the “Gang of Four” book, the Interpreter Pattern.
How do new features like sealed classes, pattern matching, records, and enhanced switch statements in today's Java change the interpreter pattern? Why is the interpreter so sought out among functional programmers? We will review the classic pattern and its purpose. We replace it with a modern alternative using the latest Java 21 techniques. We discuss its importance and use and how to wire in concepts like programs and monads, thus pushing our knowledge to Java's edge!
About Daniel Hinojosa
Daniel is a programmer, consultant, instructor, speaker, and recent author. With over 20 years of experience, he does work for private, educational, and government institutions. He is also currently a speaker for No Fluff Just Stuff tour. Daniel loves JVM languages like Java, Groovy, and Scala; but also dabbles with non JVM languages like Haskell, Ruby, Python, LISP, C, C++. He is an avid Pomodoro Technique Practitioner and makes every attempt to learn a new programming language every year. For downtime, he enjoys reading, swimming, Legos, football, and barbecuing.
More About Daniel »