The Expression Problem: Elegant Solutions in OOP and FP
2025-09-07
This article delves into the "expression problem" in software design: how to add new data types and operations without modifying existing code. The author uses C++ and Haskell examples to illustrate the limitations of object-oriented and functional programming in solving this problem. The article then explores elegant solutions using the visitor pattern and Clojure's multimethods and protocols. Clojure's approach cleverly leverages the power of open methods, separating method definitions from type definitions, enabling flexible extension without modifying existing code.