You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
Copy file name to clipboardexpand all lines: adapter/index.md
+8-5
Original file line number
Diff line number
Diff line change
@@ -10,24 +10,27 @@ tags:
10
10
- Difficulty-Beginner
11
11
---
12
12
13
-
**Also known as:** Wrapper
13
+
## Also known as
14
+
Wrapper
14
15
15
-
**Intent:** Convert the interface of a class into another interface the clients
16
+
## Intent
17
+
Convert the interface of a class into another interface the clients
16
18
expect. Adapter lets classes work together that couldn't otherwise because of
17
19
incompatible interfaces.
18
20
19
21

20
22
21
-
**Applicability:** Use the Adapter pattern when
23
+
## Applicability
24
+
Use the Adapter pattern when
22
25
23
26
* you want to use an existing class, and its interface does not match the one you need
24
27
* you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces
25
28
* 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.
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
**Applicability:** Use async method invocation pattern when
21
+
## Applicability
22
+
Use async method invocation pattern when
21
23
22
24
* you have multiple independent tasks that can run in parallel
23
25
* you need to improve the performance of a group of sequential tasks
24
26
* you have limited amount of processing capacity or long running tasks and the
25
27
caller should not wait the tasks to be ready
26
28
27
-
**Real world examples:**
29
+
## Real world examples
28
30
29
31
*[FutureTask](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/FutureTask.html), [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html) and [ExecutorService](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html) (Java)
Copy file name to clipboardexpand all lines: bridge/index.md
+7-5
Original file line number
Diff line number
Diff line change
@@ -10,22 +10,24 @@ tags:
10
10
- Difficulty-Intermediate
11
11
---
12
12
13
-
**Also known as:** Handle/Body
13
+
## Also known as
14
+
Handle/Body
14
15
15
-
**Intent:** Decouple an abstraction from its implementation so that the two can
16
+
## Intent
17
+
Decouple an abstraction from its implementation so that the two can
16
18
vary independently.
17
19
18
-
19
20

20
21
21
-
**Applicability:** Use the Bridge pattern when
22
+
## Applicability
23
+
Use the Bridge pattern when
22
24
23
25
* you want to avoid a permanent binding between an abstraction and its implementation. This might be the case, for example, when the implementation must be selected or switched at run-time.
24
26
* both the abstractions and their implementations should be extensible by subclassing. In this case, the Bridge pattern lets you combine the different abstractions and implementations and extend them independently
25
27
* changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have to be recompiled.
26
28
* 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
27
29
* 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.
28
30
29
-
**Credits**
31
+
## Credits
30
32
31
33
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
Copy file name to clipboardexpand all lines: callback/index.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -11,16 +11,18 @@ tags:
11
11
- Idiom
12
12
---
13
13
14
-
**Intent:** Callback is a piece of executable code that is passed as an
14
+
## Intent
15
+
Callback is a piece of executable code that is passed as an
15
16
argument to other code, which is expected to call back (execute) the argument
16
17
at some convenient time.
17
18
18
19

19
20
20
-
**Applicability:** Use the Callback pattern when
21
+
## Applicability
22
+
Use the Callback pattern when
21
23
22
24
* when some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.
23
25
24
-
**Real world examples:**
26
+
## Real world examples
25
27
26
28
*[CyclicBarrier] (http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CyclicBarrier.html#CyclicBarrier%28int,%20java.lang.Runnable%29) constructor can accept callback that will be triggered every time when barrier is tripped.
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
Copy file name to clipboardexpand all lines: command/index.md
+9-6
Original file line number
Diff line number
Diff line change
@@ -10,32 +10,35 @@ tags:
10
10
- Difficulty-Intermediate
11
11
---
12
12
13
-
**Also known as:** Action, Transaction
13
+
## Also known as
14
+
Action, Transaction
14
15
15
-
**Intent:** Encapsulate a request as an object, thereby letting you
16
+
## Intent
17
+
Encapsulate a request as an object, thereby letting you
16
18
parameterize clients with different requests, queue or log requests, and
17
19
support undoable operations.
18
20
19
21

20
22
21
-
**Applicability:** Use the Command pattern when you want to
23
+
## Applicability
24
+
Use the Command pattern when you want to
22
25
23
26
* parameterize objects by an action to perform. You can express such parameterization in a procedural language with a callback function, that is, a function that's registered somewhere to be called at a later point. Commands are an object-oriented replacement for callbacks.
24
27
* specify, queue, and execute requests at different times. A Command object can have a lifetime independent of the original request. If the receiver of a request can be represented in an address space-independent way, then you can transfer a command object for the request to a different process and fulfill the request there
25
28
* support undo. The Command's execute operation can store state for reversing its effects in the command itself. The Command interface must have an added Unexecute operation that reverses the effects of a previous call to execute. Executed commands are stored in a history list. Unlimited-level undo and redo is achieved by traversing this list backwards and forwards calling unexecute and execute, respectively
26
29
* support logging changes so that they can be reapplied in case of a system crash. By augmenting the Command interface with load and store operations, you can keep a persistent log of changes. Recovering from a crash involves reloading logged commands from disk and re-executing them with the execute operation
27
30
* structure a system around high-level operations build on primitive operations. Such a structure is common in information systems that support transactions. A transaction encapsulates a set of changes to data. The Command pattern offers a way to model transactions. Commands have a common interface, letting you invoke all transactions the same way. The pattern also makes it easy to extend the system with new transactions
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
Copy file name to clipboardexpand all lines: composite/index.md
+6-4
Original file line number
Diff line number
Diff line change
@@ -10,22 +10,24 @@ tags:
10
10
- Difficulty-Intermediate
11
11
---
12
12
13
-
**Intent:** Compose objects into tree structures to represent part-whole
13
+
## Intent
14
+
Compose objects into tree structures to represent part-whole
14
15
hierarchies. Composite lets clients treat individual objects and compositions
15
16
of objects uniformly.
16
17
17
18

18
19
19
-
**Applicability:** Use the Composite pattern when
20
+
## Applicability
21
+
Use the Composite pattern when
20
22
21
23
* you want to represent part-whole hierarchies of objects
22
24
* 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
23
25
24
-
**Real world examples:**
26
+
## Real world examples
25
27
26
28
*[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)
27
29
*[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)
28
30
29
-
**Credits**
31
+
## Credits
30
32
31
33
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
Copy file name to clipboardexpand all lines: decorator/index.md
+7-4
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,23 @@ tags:
10
10
- Difficulty-Beginner
11
11
---
12
12
13
-
**Also known as:** Wrapper
13
+
## Also known as
14
+
Wrapper
14
15
15
-
**Intent:** Attach additional responsibilities to an object dynamically.
16
+
## Intent
17
+
Attach additional responsibilities to an object dynamically.
16
18
Decorators provide a flexible alternative to subclassing for extending
17
19
functionality.
18
20
19
21

20
22
21
-
**Applicability:** Use Decorator
23
+
## Applicability
24
+
Use Decorator
22
25
23
26
* to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects
24
27
* for responsibilities that can be withdrawn
25
28
* 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
26
29
27
-
**Credits**
30
+
## Credits
28
31
29
32
*[Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
0 commit comments