3 ms·
Yes, the Bendersky link explains it very well. The c2 wiki Shape example is in fact an instance of the Interpreter pattern (although it doesn't mention this I
by charlysl 9y ago
Yes, the Bendersky link explains it very well.
The c2 wiki Shape example is in fact an instance of the Interpreter pattern (although it doesn't mention this I believe), which is the closest thing to pattern matching in Java (Visitor would be the other way of sort of doing pattern matching in Java, and closer to FP, with the same drawbacks and advantages).
There is another good explanation in this PDF: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-005-elements-of-software-construction-fall-2008/lecture-notes/MIT6_005f08_lec15.pdf https://ocw.mit.edu/courses/electrical-engineering-and-compu...