g ∘ f patterns
summary
Claim: most GoF behavioral patterns are boilerplate workarounds for missing higher‑order functions and Java 8 lambdas remove that boilerplate. Live‑coded examples replace Command with Runnable lists, Template with an execute(resource -> ...) using Consumer and try/finally, Decorator with function composition, Chain of Responsibility with a Stream of functions returning Optional, and an RPN interpreter using a Map<String,BinaryOperator>. Uses Java 8 lambdas, streams, Optional, DoubleUnaryOperator and reduction (identity as monoid); all examples run and produce the same results. replace GoF behavioral patterns with lambdas compose DoubleUnaryOperator via stream reduction
AI-written summary · about
chapters (10)
- 0:00Functional design patterns intro
- 3:34Command pattern functionally
- 9:35Strategy pattern with functions
- 15:54Template method as function
- 21:02Decorator via composition
- 27:54Advanced composition with monoid
- 31:09Chain of responsibility with optional
- 41:34Interpreter in functional style
- 48:07Functional interfaces and annotations
- 49:54Q&A
related talks
49mG o F Patterns
55mFunctional Programming Patterns with Java8
44mGang of Four Patterns in a Functional Light
48mRevisiting Design Patterns after 20
44mDesign Patterns in the Light of Lambda Expressions
52mFunctional Programming with Java 8
49mJava Functional Programming Idioms
56mJava Functional Programming Idioms
