From b3e4e8a47bf5f88277029534456334d9e2c59432 Mon Sep 17 00:00:00 2001 From: Narendra Pathai Date: Tue, 22 Sep 2015 18:25:56 +0530 Subject: [PATCH] Work on #226, #213, added references of Gang Of Four to all GoF patterns, added tag for Gang Of Four, added difficulty tags to some of them --- abstract-factory/index.md | 8 +++++++- adapter/index.md | 8 +++++++- bridge/index.md | 8 +++++++- builder/index.md | 8 +++++++- chain/index.md | 8 +++++++- command/index.md | 8 +++++++- composite/index.md | 8 +++++++- decorator/index.md | 8 +++++++- facade/index.md | 8 +++++++- factory-method/index.md | 5 +++++ flyweight/index.md | 8 +++++++- interpreter/index.md | 8 +++++++- iterator/index.md | 9 ++++++++- mediator/index.md | 9 ++++++++- memento/index.md | 8 +++++++- observer/index.md | 9 ++++++++- prototype/index.md | 8 +++++++- proxy/index.md | 9 ++++++++- singleton/index.md | 9 ++++++++- state/index.md | 9 ++++++++- strategy/index.md | 9 ++++++++- template-method/index.md | 9 ++++++++- visitor/index.md | 9 ++++++++- 23 files changed, 168 insertions(+), 22 deletions(-) diff --git a/abstract-factory/index.md b/abstract-factory/index.md index cb229f4ab..7db699a99 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 23aaeadcc..be9a87228 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 6ef1c6519..1ad969183 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 aa5c86201..f350638d2 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 25e14bf06..9be376324 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 23582406e..c9790819f 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 374e1d5aa..4a31a1b33 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 02f129258..55849fce6 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 0f6e2fbb1..59ff888b2 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 8011e42c8..fee6b6e83 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 85fa54ad1..e2273c197 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 c7c4539d5..57b117e06 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 63bdaf516..ecfdb1b2a 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 e67218a53..cb4ce7fb1 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 b91e34739..056af8b26 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 d5b380a30..fedb4cb8c 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 cab97f7dc..9d108ff06 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 96ea40714..f863a96a5 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 7a280bdfa..18c137448 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 1b1e4717f..b743cb8be 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 1d3250517..120dd64d4 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 f647d2cd5..8b8b7878e 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 eeb11a5e5..5f32edbbd 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) -- GitLab