|
50 | 50 | * you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
|
51 | 51 |
|
52 | 52 | **Real world examples:**
|
53 |
| -* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html) |
| 53 | +* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html) |
54 | 54 |
|
55 | 55 | ## <a name="builder">Builder</a> [↑](#list-of-design-patterns)
|
56 | 56 | **Intent:** Separate the construction of a complex object from its representation so that the same construction process can create different representations.
|
|
62 | 62 | * the construction process must allow different representations for the object that's constructed
|
63 | 63 |
|
64 | 64 | **Real world examples:**
|
65 |
| -* [java.lang.StringBuilder](http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuilder.html) |
| 65 | +* [java.lang.StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html) |
66 | 66 |
|
67 | 67 | ## <a name="factory-method">Factory Method</a> [↑](#list-of-design-patterns)
|
68 | 68 | **Intent:** Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
|
|
75 | 75 | * classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate
|
76 | 76 |
|
77 | 77 | **Real world examples:**
|
78 |
| -* [java.util.Calendar#getInstance()](http://docs.oracle.com/javase/6/docs/api/java/util/Calendar.html#getInstance%28%29) |
| 78 | +* [java.util.Calendar#getInstance()](http://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getInstance%28%29) |
79 | 79 |
|
80 | 80 | ## <a name="prototype">Prototype</a> [↑](#list-of-design-patterns)
|
81 | 81 | **Intent:** Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
|
|
88 | 88 | * when instances of a class can have one of only a few different combinations of state. It may be more convenient to install a corresponding number of prototypes and clone them rather than instantiating the class manually, each time with the appropriate state
|
89 | 89 |
|
90 | 90 | **Real world examples:**
|
91 |
| -* [java.lang.Object#clone()](http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html#clone%28%29) |
| 91 | +* [java.lang.Object#clone()](http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone%28%29) |
92 | 92 |
|
93 | 93 | ## <a name="singleton">Singleton</a> [↑](#list-of-design-patterns)
|
94 | 94 | **Intent:** Ensure a class only has one instance, and provide a global point of access to it.
|
|
105 | 105 | * file manager
|
106 | 106 |
|
107 | 107 | **Real world examples:**
|
108 |
| -* [java.lang.Runtime#getRuntime()](http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#getRuntime%28%29) |
| 108 | +* [java.lang.Runtime#getRuntime()](http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#getRuntime%28%29) |
109 | 109 |
|
110 | 110 | ## <a name="adapter">Adapter</a> [↑](#list-of-design-patterns)
|
111 | 111 | **Intent:** Convert the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
|
|
118 | 118 | * you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class.
|
119 | 119 |
|
120 | 120 | **Real world examples:**
|
121 |
| -* [java.util.Arrays#asList()](http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList%28T...%29) |
| 121 | +* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29) |
122 | 122 |
|
123 | 123 | ## <a name="bridge">Bridge</a> [↑](#list-of-design-patterns)
|
124 | 124 | **Intent:** Decouple an abstraction from its implementation so that the two can vary independently.
|
|
143 | 143 | * you want clients to be able to ignore the difference between compositions of objects and individual objects. Clients will treat all objects in the composite structure uniformly
|
144 | 144 |
|
145 | 145 | **Real world examples:**
|
146 |
| -* [java.awt.Container](http://docs.oracle.com/javase/6/docs/api/java/awt/Container.html) and [java.awt.Component](http://docs.oracle.com/javase/6/docs/api/java/awt/Component.html) |
| 146 | +* [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) |
147 | 147 | * [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)
|
148 | 148 |
|
149 | 149 | ## <a name="decorator">Decorator</a> [↑](#list-of-design-patterns)
|
|
179 | 179 | * the application doesn't depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects.
|
180 | 180 |
|
181 | 181 | **Real world examples:**
|
182 |
| -* [java.lang.Integer#valueOf(int)](http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#valueOf%28int%29) |
| 182 | +* [java.lang.Integer#valueOf(int)](http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#valueOf%28int%29) |
183 | 183 |
|
184 | 184 | ## <a name="proxy">Proxy</a> [↑](#list-of-design-patterns)
|
185 | 185 | **Intent:** Provide a surrogate or placeholder for another object to control access to it.
|
|
201 | 201 | * to count references to an object
|
202 | 202 |
|
203 | 203 | **Real world examples:**
|
204 |
| -* [java.lang.reflect.Proxy](http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Proxy.html) |
| 204 | +* [java.lang.reflect.Proxy](http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Proxy.html) |
205 | 205 |
|
206 | 206 | ## <a name="service-locator">Service Locator</a> [↑](#list-of-design-patterns)
|
207 | 207 | **Intent:** Encapsulate the processes involved in obtaining a service with a strong abstraction layer.
|
|
227 | 227 | * the set of objects that can handle a request should be specified dynamically
|
228 | 228 |
|
229 | 229 | **Real world examples:**
|
230 |
| -* [java.util.logging.Logger#log()](http://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html#log%28java.util.logging.Level,%20java.lang.String%29) |
| 230 | +* [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) |
231 | 231 |
|
232 | 232 | ## <a name="command">Command</a> [↑](#list-of-design-patterns)
|
233 | 233 | **Intent:** Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.
|
|
249 | 249 | * implement the undo functionality
|
250 | 250 |
|
251 | 251 | **Real world examples:**
|
252 |
| -* [java.lang.Runnable](http://docs.oracle.com/javase/6/docs/api/java/lang/Runnable.html) |
| 252 | +* [java.lang.Runnable](http://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html) |
253 | 253 |
|
254 | 254 | ## <a name="interpreter">Interpreter</a> [↑](#list-of-design-patterns)
|
255 | 255 | **Intent:** Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
|
|
271 | 271 | * to provide a uniform interface for traversing different aggregate structures
|
272 | 272 |
|
273 | 273 | **Real world examples:**
|
274 |
| -* [java.util.Iterator](http://docs.oracle.com/javase/6/docs/api/java/util/Iterator.html) |
| 274 | +* [java.util.Iterator](http://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html) |
275 | 275 |
|
276 | 276 | ## <a name="mediator">Mediator</a> [↑](#list-of-design-patterns)
|
277 | 277 | **Intent:** Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
|
|
293 | 293 | * a direct interface to obtaining the state would expose implementation details and break the object's encapsulation
|
294 | 294 |
|
295 | 295 | **Real world examples:**
|
296 |
| -* [java.util.Date](http://docs.oracle.com/javase/6/docs/api/java/util/Date.html) |
| 296 | +* [java.util.Date](http://docs.oracle.com/javase/8/docs/api/java/util/Date.html) |
297 | 297 |
|
298 | 298 | ## <a name="observer">Observer</a> [↑](#list-of-design-patterns)
|
299 | 299 | **Intent:** Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
|
|
311 | 311 | * changing in one object leads to a change in other objects
|
312 | 312 |
|
313 | 313 | **Real world examples:**
|
314 |
| -* [java.util.Observer](http://docs.oracle.com/javase/6/docs/api/java/util/Observer.html) |
| 314 | +* [java.util.Observer](http://docs.oracle.com/javase/8/docs/api/java/util/Observer.html) |
315 | 315 |
|
316 | 316 | ## <a name="state">State</a> [↑](#list-of-design-patterns)
|
317 | 317 | **Intent:** Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
|
|
0 commit comments