Awesome
Design Patterns Reloaded
Implementation of some design patterns in Java 21, some of them are from the GoF, others are the one you usually see in programs.
Like most of the GoF patterns, the implementations use delegation instead of inheritance, but also emphasis immutability when necessary.
- abstract factory abstracts access to several factories
- adapter to see an object from one interface as one from another interface
- builder constructs objects by name instead of by position
- chain of responsibility constructs a pipeline of objects that handle a request
- command, objects that are actions
- decorator dynamically adds behavior to an existing object
- factory abstracts the creation of objects
- memoizer caches the result of a computation to avoid multiple re-computations of the same value
- monad wraps multiple disjoint states under a common API
- observer de-couples codes by pushing the values from an object to another one
- proxy see decorator
- singleton see abstract-factory
- railwayswitch abstracts a cascade of if ... else
- state delegates API implementation to an internal state object
- template_method define a behavior with a generic part and a specific part
- typing, 3 kinds of relations between a static type and a runtime class
- visitor / pattern matching, specify operations on a hierarchy of types outside that hierarchy
Old materials
I've done a presentation in English at Devoxx 2015
Corresponding slides used for my presentation at ParisJUG in June 2015.
NB: A port exists in Scala