A Builder implementation in Swift.
tl;dr Creational patterns specifically deal with the creation of objects/entities in the code. They abstract the instantiation process (meaning that most of the time, they provide an abstraction layer above the use of the raw language facilities to construct an object). They help make a system independent of how its objects are created, composed, and represented.
tl;dr Patterns, 20 Years Later: The Builder pattern has enjoyed some success within the O-O community, particularly among the crowd that sees it as a way to build fluent APIs (APIs which read, more or less, like a natural language, a la English). Builder has a few tricks up its sleeve beyond just fluent APIs, however.
A Constructor Function implementation in Swift.
A Closure-based State implementation in Swift.
tl;dr Recently the Harvard Business Review ran an article on how readers could prepare for difficult business situations, using the analogy of coaches preparing their teams for different eventualities by simulating those eventualities on the practice field. There’s lessons to be learned here for both programming and speaking.
Let’s talk a bit about the various pattern implementations, the languages in which they are being written, and what to “get” out of them.
A Closure-based State implementation in F#.
A Closure-based State implementation in Java.