diff --git a/abstract-factory/index.md b/abstract-factory/index.md index cb229f4ab8f9b8a06d0b968cf01abe7b620da857..7db699a99f576ef497dc1894d36f52ec617aa38b 100644 --- a/abstract-factory/index.md +++ b/abstract-factory/index.md @@ -4,7 +4,9 @@ title: Abstract Factory folder: abstract-factory permalink: /patterns/abstract-factory/ categories: Creational -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Provide an interface for creating families of related or dependent @@ -22,3 +24,7 @@ objects without specifying their concrete classes. **Real world examples:** * [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/adapter/index.md b/adapter/index.md index 23aaeadcc3fc23407c6777b620da92e49a81c3f4..be9a8722838799be8d8cea7aee8e0adbd68bf286 100644 --- a/adapter/index.md +++ b/adapter/index.md @@ -4,7 +4,9 @@ title: Adapter folder: adapter permalink: /patterns/adapter/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Convert the interface of a class into another interface the clients @@ -22,3 +24,7 @@ incompatible interfaces. **Real world examples:** * [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/bridge/index.md b/bridge/index.md index 6ef1c6519f22364e544fb8012945efe886285a37..1ad969183df058a7051368b6f1c8abe9c027b033 100644 --- a/bridge/index.md +++ b/bridge/index.md @@ -4,7 +4,9 @@ title: Bridge folder: bridge permalink: /patterns/bridge/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Decouple an abstraction from its implementation so that the two can @@ -20,3 +22,7 @@ vary independently. * changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have to be recompiled. * you have a proliferation of classes. Such a class hierarchy indicates the need for splitting an object into two parts. Rumbaugh uses the term "nested generalizations" to refer to such class hierarchies * you want to share an implementation among multiple objects (perhaps using reference counting), and this fact should be hidden from the client. A simple example is Coplien's String class, in which multiple objects can share the same string representation. + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/builder/index.md b/builder/index.md index aa5c8620107c008288abe2891215acf2cd2e1865..f350638d24d626f136779e88d839bb47c7890a3a 100644 --- a/builder/index.md +++ b/builder/index.md @@ -4,7 +4,9 @@ title: Builder folder: builder permalink: /patterns/builder/ categories: Creational -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Separate the construction of a complex object from its @@ -22,3 +24,7 @@ representations. * [java.lang.StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html) * [Apache Camel builders](https://github.com/apache/camel/tree/0e195428ee04531be27a0b659005e3aa8d159d23/camel-core/src/main/java/org/apache/camel/builder) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/chain/index.md b/chain/index.md index 25e14bf06e8805d0ee99e4f0a8915a83bd4414dc..9be3763246fd055147e1268b6883fb32de6a1f33 100644 --- a/chain/index.md +++ b/chain/index.md @@ -4,7 +4,9 @@ title: Chain of responsibility folder: chain permalink: /patterns/chain/ categories: Behavioral -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Avoid coupling the sender of a request to its receiver by giving @@ -23,3 +25,7 @@ objects and pass the request along the chain until an object handles it. * [java.util.logging.Logger#log()](http://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html#log%28java.util.logging.Level,%20java.lang.String%29) * [Apache Commons Chain](https://commons.apache.org/proper/commons-chain/index.html) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/command/index.md b/command/index.md index 23582406e1aa93ee0ad365996487b7f3a5778539..c9790819faa16ee4a25fa687b6aaede5cac9b915 100644 --- a/command/index.md +++ b/command/index.md @@ -4,7 +4,9 @@ title: Command folder: command permalink: /patterns/command/ categories: Behavioral -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Encapsulate a request as an object, thereby letting you @@ -30,3 +32,7 @@ support undoable operations. **Real world examples:** * [java.lang.Runnable](http://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/composite/index.md b/composite/index.md index 374e1d5aa83104a79e431fc49550392e3b2dc8f4..4a31a1b33984323968ab7a787ed63851a91bdb53 100644 --- a/composite/index.md +++ b/composite/index.md @@ -4,7 +4,9 @@ title: Composite folder: composite permalink: /patterns/composite/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Compose objects into tree structures to represent part-whole @@ -22,3 +24,7 @@ of objects uniformly. * [java.awt.Container](http://docs.oracle.com/javase/8/docs/api/java/awt/Container.html) and [java.awt.Component](http://docs.oracle.com/javase/8/docs/api/java/awt/Component.html) * [Apache Wicket](https://github.com/apache/wicket) component tree, see [Component](https://github.com/apache/wicket/blob/91e154702ab1ff3481ef6cbb04c6044814b7e130/wicket-core/src/main/java/org/apache/wicket/Component.java) and [MarkupContainer](https://github.com/apache/wicket/blob/b60ec64d0b50a611a9549809c9ab216f0ffa3ae3/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/decorator/index.md b/decorator/index.md index 02f129258c99c67633a6ead87b4f4a8202eb9af4..55849fce6e9002364c9db8659baf19017e233d8f 100644 --- a/decorator/index.md +++ b/decorator/index.md @@ -4,7 +4,9 @@ title: Decorator folder: decorator permalink: /patterns/decorator/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Attach additional responsibilities to an object dynamically. @@ -18,3 +20,7 @@ functionality. * to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects * for responsibilities that can be withdrawn * when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/facade/index.md b/facade/index.md index 0f6e2fbb1b1f7e10b4a9955a48e8dff7df001a48..59ff888b2fe8ab3bef6a0f34fd40795eafc81b2f 100644 --- a/facade/index.md +++ b/facade/index.md @@ -4,7 +4,9 @@ title: Facade folder: facade permalink: /patterns/facade/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Provide a unified interface to a set of interfaces in a subsystem. @@ -17,3 +19,7 @@ Facade defines a higher-level interface that makes the subsystem easier to use. * you want to provide a simple interface to a complex subsystem. Subsystems often get more complex as they evolve. Most patterns, when applied, result in more and smaller classes. This makes the subsystem more reusable and easier to customize, but it also becomes harder to use for clients that don't need to customize it. A facade can provide a simple default view of the subsystem that is good enough for most clients. Only clients needing more customizability will need to look beyond the facade. * there are many dependencies between clients and the implementation classes of an abstraction. Introduce a facade to decouple the subsystem from clients and other subsystems, thereby promoting subsystem independence and portability. * you want to layer your subsystems. Use a facade to define an entry point to each subsystem level. If subsystems are dependent, the you can simplify the dependencies between them by making them communicate with each other solely through their facades + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/factory-method/index.md b/factory-method/index.md index 8011e42c8a34616af91cd815f3a2c36cb4c2b3d9..fee6b6e8352ca00cbea1ee79d60ad89285221b4c 100644 --- a/factory-method/index.md +++ b/factory-method/index.md @@ -7,6 +7,7 @@ categories: Creational tags: - Java - Difficulty-Beginner + - Gang Of Four --- **Intent:** Define an interface for creating an object, but let subclasses @@ -20,3 +21,7 @@ instantiation to subclasses. * a class can't anticipate the class of objects it must create * a class wants its subclasses to specify the objects it creates * classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/flyweight/index.md b/flyweight/index.md index 85fa54ad1b854aee3b20dee4b3e7f88e4324be8c..e2273c197b97a5544a44d7559163098d13bfefc8 100644 --- a/flyweight/index.md +++ b/flyweight/index.md @@ -4,7 +4,9 @@ title: Flyweight folder: flyweight permalink: /patterns/flyweight/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Use sharing to support large numbers of fine-grained objects @@ -25,3 +27,7 @@ true **Real world examples:** * [java.lang.Integer#valueOf(int)](http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#valueOf%28int%29) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/interpreter/index.md b/interpreter/index.md index c7c4539d53bd2b916c4a1221a4bd9effcda3f8ae..57b117e06f6e07ca19071ee549a1aab1b19cb34b 100644 --- a/interpreter/index.md +++ b/interpreter/index.md @@ -4,7 +4,9 @@ title: Interpreter folder: interpreter permalink: /patterns/interpreter/ categories: Behavioral -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Given a language, define a representation for its grammar along @@ -19,3 +21,7 @@ trees. The Interpreter pattern works best when * the grammar is simple. For complex grammars, the class hierarchy for the grammar becomes large and unmanageable. Tools such as parser generators are a better alternative in such cases. They can interpret expressions without building abstract syntax trees, which can save space and possibly time * efficiency is not a critical concern. The most efficient interpreters are usually not implemented by interpreting parse trees directly but by first translating them into another form. For example, regular expressions are often transformed into state machines. But even then, the translator can be implemented by the Interpreter pattern, so the pattern is still applicable + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/iterator/index.md b/iterator/index.md index 63bdaf516af61679af89bf4290e3433b699f89f5..ecfdb1b2a841719aab53a4c90230dd9eba77ff3b 100644 --- a/iterator/index.md +++ b/iterator/index.md @@ -4,7 +4,10 @@ title: Iterator folder: iterator permalink: /patterns/iterator/ categories: Behavioral -tags: Java +tags: + - Java + - Difficulty-Beginner + - Gang Of Four --- **Intent:** Provide a way to access the elements of an aggregate object @@ -21,3 +24,7 @@ sequentially without exposing its underlying representation. **Real world examples:** * [java.util.Iterator](http://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/mediator/index.md b/mediator/index.md index e67218a53600f605c10b8c4e57ad00547df9b296..cb4ce7fb17f189d9b8f8b7239aa2e320d1b90cbe 100644 --- a/mediator/index.md +++ b/mediator/index.md @@ -4,7 +4,10 @@ title: Mediator folder: mediator permalink: /patterns/mediator/ categories: Behavioral -tags: Java +tags: + - Java + - Gang Of Four + - Difficulty-Intermediate --- **Intent:** Define an object that encapsulates how a set of objects interact. @@ -18,3 +21,7 @@ other explicitly, and it lets you vary their interaction independently. * a set of objects communicate in well-defined but complex ways. The resulting interdependencies are unstructured and difficult to understand * reusing an object is difficult because it refers to and communicates with many other objects * a behavior that's distributed between several classes should be customizable without a lot of subclassing + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/memento/index.md b/memento/index.md index b91e3473947846b24505cc9e7c868f940e4be520..056af8b2627942a07f86732536b21daeae4f1492 100644 --- a/memento/index.md +++ b/memento/index.md @@ -4,7 +4,9 @@ title: Memento folder: memento permalink: /patterns/memento/ categories: Behavioral -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Without violating encapsulation, capture and externalize an @@ -20,3 +22,7 @@ object's internal state so that the object can be restored to this state later. **Real world examples:** * [java.util.Date](http://docs.oracle.com/javase/8/docs/api/java/util/Date.html) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/observer/index.md b/observer/index.md index d5b380a30c18144fd8570b1a8133a16e0b70204e..fedb4cb8cfc48bb15585ea0ffdc57da7f003525f 100644 --- a/observer/index.md +++ b/observer/index.md @@ -4,7 +4,10 @@ title: Observer folder: observer permalink: /patterns/observer/ categories: Behavioral -tags: Java +tags: + - Java + - Difficulty-Beginner + - Gang Of Four --- **Intent:** Define a one-to-many dependency between objects so that when one @@ -26,3 +29,7 @@ automatically. **Real world examples:** * [java.util.Observer](http://docs.oracle.com/javase/8/docs/api/java/util/Observer.html) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/prototype/index.md b/prototype/index.md index cab97f7dcf3e576dc50224e6aa249d2b94866fb9..9d108ff064259879af147ae8d3c285cb41aa40a2 100644 --- a/prototype/index.md +++ b/prototype/index.md @@ -4,7 +4,9 @@ title: Prototype folder: prototype permalink: /patterns/prototype/ categories: Creational -tags: Java +tags: + - Java + - Gang Of Four --- **Intent:** Specify the kinds of objects to create using a prototypical @@ -21,3 +23,7 @@ instance, and create new objects by copying this prototype. **Real world examples:** * [java.lang.Object#clone()](http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone%28%29) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/proxy/index.md b/proxy/index.md index 96ea40714d86d1860884c24553557f443ef0b5e1..f863a96a554e67e631033e71ba131bfb5d2ea6a7 100644 --- a/proxy/index.md +++ b/proxy/index.md @@ -4,7 +4,10 @@ title: Proxy folder: proxy permalink: /patterns/proxy/ categories: Structural -tags: Java +tags: + - Java + - Gang Of Four + - Difficulty-Intermediate --- **Intent:** Provide a surrogate or placeholder for another object to control @@ -32,3 +35,7 @@ are several common situations in which the Proxy pattern is applicable * [java.lang.reflect.Proxy](http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Proxy.html) * [Apache Commons Proxy](https://commons.apache.org/proper/commons-proxy/) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/singleton/index.md b/singleton/index.md index 7a280bdfa78b80e2ba1865275e112d67a626441f..18c137448509497b36137eee312c883e5bb1f74a 100644 --- a/singleton/index.md +++ b/singleton/index.md @@ -4,7 +4,10 @@ title: Singleton folder: singleton permalink: /patterns/singleton/ categories: Creational -tags: Java +tags: + - Java + - Gang Of Four + - Difficulty-Beginner --- **Intent:** Ensure a class only has one instance, and provide a global point of @@ -26,3 +29,7 @@ access to it. **Real world examples:** * [java.lang.Runtime#getRuntime()](http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#getRuntime%28%29) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/state/index.md b/state/index.md index 1b1e4717fac182a4e3a6a932c3aa1bdcdf4058b8..b743cb8bedfbaa0ac31636b9f82153d0d73422b4 100644 --- a/state/index.md +++ b/state/index.md @@ -4,7 +4,10 @@ title: State folder: state permalink: /patterns/state/ categories: Behavioral -tags: Java +tags: + - Java + - Difficulty-Intermediate + - Gang Of Four --- **Intent:** Allow an object to alter its behavior when its internal state @@ -16,3 +19,7 @@ changes. The object will appear to change its class. * an object's behavior depends on its state, and it must change its behavior at run-time depending on that state * operations have large, multipart conditional statements that depend on the object's state. This state is usually represented by one or more enumerated constants. Often, several operations will contain this same conditional structure. The State pattern puts each branch of the conditional in a separate class. This lets you treat the object's state as an object in its own right that can vary independently from other objects. + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/strategy/index.md b/strategy/index.md index 1d3250517716e8ae5962804602feae53af5ff661..120dd64d485e77d358b95eb221401802e38e58b8 100644 --- a/strategy/index.md +++ b/strategy/index.md @@ -4,7 +4,10 @@ title: Strategy folder: strategy permalink: /patterns/strategy/ categories: Behavioral -tags: Java +tags: + - Java + - Difficulty-Beginner + - Gang Of Four --- **Intent:** Define a family of algorithms, encapsulate each one, and make them @@ -19,3 +22,7 @@ that use it. * you need different variants of an algorithm. for example, you might define algorithms reflecting different space/time trade-offs. Strategies can be used when these variants are implemented as a class hierarchy of algorithms * an algorithm uses data that clients shouldn't know about. Use the Strategy pattern to avoid exposing complex, algorithm-specific data structures * a class defines many behaviors, and these appear as multiple conditional statements in its operations. Instead of many conditionals, move related conditional branches into their own Strategy class + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/template-method/index.md b/template-method/index.md index f647d2cd59068a7404355cac6a1cf7b922b81008..8b8b7878e290935ae4999d9c436434380421764a 100644 --- a/template-method/index.md +++ b/template-method/index.md @@ -4,7 +4,10 @@ title: Template method folder: template-method permalink: /patterns/template-method/ categories: Behavioral -tags: Java +tags: + - Java + - Difficulty-Beginner + - Gang Of Four --- **Intent:** Define the skeleton of an algorithm in an operation, deferring some @@ -18,3 +21,7 @@ an algorithm without changing the algorithm's structure. * to implement the invariant parts of an algorithm once and leave it up to subclasses to implement the behavior that can vary * when common behavior among subclasses should be factored and localized in a common class to avoid code duplication. This is good example of "refactoring to generalize" as described by Opdyke and Johnson. You first identify the differences in the existing code and then separate the differences into new operations. Finally, you replace the differing code with a template method that calls one of these new operations * to control subclasses extensions. You can define a template method that calls "hook" operations at specific points, thereby permitting extensions only at those points + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) diff --git a/visitor/index.md b/visitor/index.md index eeb11a5e55a9acbfd870efdd7f30982921a16665..5f32edbbdfd877a668d5d5b442ad94b7cf3cb418 100644 --- a/visitor/index.md +++ b/visitor/index.md @@ -4,7 +4,10 @@ title: Visitor folder: visitor permalink: /patterns/visitor/ categories: Behavioral -tags: Java +tags: + - Java + - Difficulty-Expert + - Gang Of Four --- **Intent:** Represent an operation to be performed on the elements of an object @@ -22,3 +25,7 @@ of the elements on which it operates. **Real world examples:** * [Apache Wicket](https://github.com/apache/wicket) component tree, see [MarkupContainer](https://github.com/apache/wicket/blob/b60ec64d0b50a611a9549809c9ab216f0ffa3ae3/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java) + +**Credits** + +* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)