~~NOTOC~~ ====== Scala design patterns ====== This section lists some design patterns which are useful in Scala programs. There's also the [[pattern replacements]] page, which describes ways in which Scala language features make some common patterns unnecessary. /*TOC*/ ===== Structural patterns ===== * [[Component mixins|Cake]] - Build components which are abstracted over their dependencies. * [[Dynamic scope]] - Make certain information available in a given context without explicitly passing it about. * [[Utility belt]] - Lightweight crosscutting resource sharing. * [[Reactive abstractions]] - Discussion of the relationship among Actors, Arrows, FRP, Pub-Sub, .... * [[Pimp my library]] - Extend existing classes with new methods * [[Duck typing done right]] - Utilise "duck typing" (structural typing) like a pro * [[Memoization]] - Memoize the result of a function ===== Behavioural patterns ===== * [[Loan]] - Used primarily for resource disposal; equivalent to C++ RAII or C# 'using'. ===== GoF Design Patterns ==== /*SKIP*/These patterns are provided as references to help programmers from other Object-oriented languages see how the classic GoF Design Patterns can be applied using idiomatic Scala. Of course all of these patterns can be realized using only Scala's OO features, much as they can in Java or C++, but many have much more concise and/or robust representations in Scala./*/SKIP*/ === Creational Patterns === * [[GoFAbstractFactory|Abstract Factory]] * [[GoFBuilder|Builder]] * [[GoFFactoryMethod|Factory Method]] * [[GoFPrototype|Prototype]] * [[GoFSingleton|Singleton]] === Structural Patterns === * [[GoFAdapter|Adapter]] * [[GoFBridge|Bridge]] * [[GoFComposite|Composite]] * [[GoFDecorator|Decorator]] * [[GoFFacade|Facade]] * [[GoFFlyweight|Flyweight]] * [[GoFProxy|Proxy]] === Behavior Patterns === * [[GoFChainOfResponsibility|Chain of Responsibility]] * [[GoFCommand|Command]] * [[GoFInterpreter|Interpreter]] * [[GoFIterator|Iterator]] * [[GoFMediator|Mediator]] * [[GoFMemento|Memento]] * [[GoFObserver|Observer]] * [[GoFState|State]] * [[GoFStrategy|Strategy]] * [[GoFTemplateMethod|Template Method]] * [[GoFVisitor|Visitor]] /*/TOC*/