Module 27 ยท Design Patterns (All 23 GoF) โ Lesson 15 of 23 ยท ~6 min
Interpreter
Evaluate sentences in a tiny language
Interpreter defines a grammar and an evaluator for a small domain language. Honestly? This is the rarest GoF pattern in everyday app code โ if you need a real language you reach for a parser library, not hand-rolled Interpreter classes. But a tiny rule language shows the idea.
PawWalk scenario: a price-adjustment rule expressed as tokens like ("add", 500), ("sub", 200), evaluated against a starting total.