Skip to content

Commit

Permalink
Use headings instead of bold text in index.md #238
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxw42 committed Jan 3, 2016
1 parent b6beffe commit 3d642cd
Show file tree
Hide file tree
Showing 66 changed files with 373 additions and 233 deletions.
13 changes: 8 additions & 5 deletions abstract-factory/index.md
Expand Up @@ -10,24 +10,27 @@ tags:
- Difficulty-Intermediate
---

**Also known as:** Kit
## Also known as
Kit

**Intent:** Provide an interface for creating families of related or dependent
## Intent
Provide an interface for creating families of related or dependent
objects without specifying their concrete classes.

![alt text](./etc/abstract-factory_1.png "Abstract Factory")

**Applicability:** Use the Abstract Factory pattern when
## Applicability
Use the Abstract Factory pattern when

* a system should be independent of how its products are created, composed and represented
* a system should be configured with one of multiple families of products
* a family of related product objects is designed to be used together, and you need to enforce this constraint
* you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations

**Real world examples:**
## Real world examples

* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)

**Credits**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
13 changes: 8 additions & 5 deletions adapter/index.md
Expand Up @@ -10,24 +10,27 @@ tags:
- Difficulty-Beginner
---

**Also known as:** Wrapper
## Also known as
Wrapper

**Intent:** Convert the interface of a class into another interface the clients
## 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.

![alt text](./etc/adapter.png "Adapter")

**Applicability:** Use the Adapter pattern when
## Applicability
Use the Adapter pattern when

* you want to use an existing class, and its interface does not match the one you need
* you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces
* 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.

**Real world examples:**
## Real world examples

* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)

**Credits**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
8 changes: 5 additions & 3 deletions async-method-invocation/index.md
Expand Up @@ -10,21 +10,23 @@ tags:
- Functional
---

**Intent:** Asynchronous method invocation is pattern where the calling thread
## Intent
Asynchronous method invocation is pattern where the calling thread
is not blocked while waiting results of tasks. The pattern provides parallel
processing of multiple independent tasks and retrieving the results via
callbacks or waiting until everything is done.

![alt text](./etc/async-method-invocation.png "Async Method Invocation")

**Applicability:** Use async method invocation pattern when
## Applicability
Use async method invocation pattern when

* you have multiple independent tasks that can run in parallel
* you need to improve the performance of a group of sequential tasks
* you have limited amount of processing capacity or long running tasks and the
caller should not wait the tasks to be ready

**Real world examples:**
## Real world examples

* [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)
* [Task-based Asynchronous Pattern](https://msdn.microsoft.com/en-us/library/hh873175.aspx) (.NET)
12 changes: 7 additions & 5 deletions bridge/index.md
Expand Up @@ -10,22 +10,24 @@ tags:
- Difficulty-Intermediate
---

**Also known as:** Handle/Body
## Also known as
Handle/Body

**Intent:** Decouple an abstraction from its implementation so that the two can
## Intent
Decouple an abstraction from its implementation so that the two can
vary independently.


![alt text](./etc/bridge.png "Bridge")

**Applicability:** Use the Bridge pattern when
## Applicability
Use the Bridge pattern when

* 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.
* 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
* 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**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
10 changes: 6 additions & 4 deletions builder/index.md
Expand Up @@ -10,22 +10,24 @@ tags:
- Difficulty-Intermediate
---

**Intent:** Separate the construction of a complex object from its
## Intent
Separate the construction of a complex object from its
representation so that the same construction process can create different
representations.

![alt text](./etc/builder_1.png "Builder")

**Applicability:** Use the Builder pattern when
## Applicability
Use the Builder pattern when

* the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled
* the construction process must allow different representations for the object that's constructed

**Real world examples:**
## Real world examples

* [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**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
6 changes: 4 additions & 2 deletions business-delegate/index.md
Expand Up @@ -9,14 +9,16 @@ tags:
- Difficulty-Intermediate
---

**Intent:** The Business Delegate pattern adds an abstraction layer between
## Intent
The Business Delegate pattern adds an abstraction layer between
presentation and business tiers. By using the pattern we gain loose coupling
between the tiers and encapsulate knowledge about how to locate, connect to,
and interact with the business objects that make up the application.

![alt text](./etc/business-delegate.png "Business Delegate")

**Applicability:** Use the Business Delegate pattern when
## Applicability
Use the Business Delegate pattern when

* you want loose coupling between presentation and business tiers
* you want to orchestrate calls to multiple business services
Expand Down
8 changes: 5 additions & 3 deletions caching/index.md
Expand Up @@ -10,17 +10,19 @@ tags:
- Performance
---

**Intent:** To avoid expensive re-acquisition of resources by not releasing
## Intent
To avoid expensive re-acquisition of resources by not releasing
the resources immediately after their use. The resources retain their identity, are kept in some
fast-access storage, and are re-used to avoid having to acquire them again.

![alt text](./etc/caching.png "Caching")

**Applicability:** Use the Caching pattern(s) when
## Applicability
Use the Caching pattern(s) when

* Repetitious acquisition, initialization, and release of the same resource causes unnecessary performance overhead.

**Credits**
## Credits

* [Write-through, write-around, write-back: Cache explained](http://www.computerweekly.com/feature/Write-through-write-around-write-back-Cache-explained)
* [Read-Through, Write-Through, Write-Behind, and Refresh-Ahead Caching](https://docs.oracle.com/cd/E15357_01/coh.360/e15723/cache_rtwtwbra.htm#COHDG5177)
8 changes: 5 additions & 3 deletions callback/index.md
Expand Up @@ -11,16 +11,18 @@ tags:
- Idiom
---

**Intent:** Callback is a piece of executable code that is passed as an
## Intent
Callback is a piece of executable code that is passed as an
argument to other code, which is expected to call back (execute) the argument
at some convenient time.

![alt text](./etc/callback.png "Callback")

**Applicability:** Use the Callback pattern when
## Applicability
Use the Callback pattern when

* when some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.

**Real world examples:**
## Real world examples

* [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.
10 changes: 6 additions & 4 deletions chain/index.md
Expand Up @@ -10,23 +10,25 @@ tags:
- Difficulty-Intermediate
---

**Intent:** Avoid coupling the sender of a request to its receiver by giving
## Intent
Avoid coupling the sender of a request to its receiver by giving
more than one object a chance to handle the request. Chain the receiving
objects and pass the request along the chain until an object handles it.

![alt text](./etc/chain_1.png "Chain of Responsibility")

**Applicability:** Use Chain of Responsibility when
## Applicability
Use Chain of Responsibility when

* more than one object may handle a request, and the handler isn't known a priori. The handler should be ascertained automatically
* you want to issue a request to one of several objects without specifying the receiver explicitly
* the set of objects that can handle a request should be specified dynamically

**Real world examples:**
## Real world examples

* [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**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
15 changes: 9 additions & 6 deletions command/index.md
Expand Up @@ -10,32 +10,35 @@ tags:
- Difficulty-Intermediate
---

**Also known as:** Action, Transaction
## Also known as
Action, Transaction

**Intent:** Encapsulate a request as an object, thereby letting you
## Intent
Encapsulate a request as an object, thereby letting you
parameterize clients with different requests, queue or log requests, and
support undoable operations.

![alt text](./etc/command.png "Command")

**Applicability:** Use the Command pattern when you want to
## Applicability
Use the Command pattern when you want to

* 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.
* 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
* 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
* 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
* 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

**Typical Use Case:**
## Typical Use Case

* to keep a history of requests
* implement callback functionality
* implement the undo functionality

**Real world examples:**
## Real world examples

* [java.lang.Runnable](http://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html)

**Credits**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
10 changes: 6 additions & 4 deletions composite/index.md
Expand Up @@ -10,22 +10,24 @@ tags:
- Difficulty-Intermediate
---

**Intent:** Compose objects into tree structures to represent part-whole
## Intent
Compose objects into tree structures to represent part-whole
hierarchies. Composite lets clients treat individual objects and compositions
of objects uniformly.

![alt text](./etc/composite_1.png "Composite")

**Applicability:** Use the Composite pattern when
## Applicability
Use the Composite pattern when

* you want to represent part-whole hierarchies of objects
* 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

**Real world examples:**
## Real world examples

* [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**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
8 changes: 5 additions & 3 deletions dao/index.md
Expand Up @@ -9,16 +9,18 @@ tags:
- Difficulty-Beginner
---

**Intent:** Object provides an abstract interface to some type of database or
## Intent
Object provides an abstract interface to some type of database or
other persistence mechanism.

![alt text](./etc/dao.png "Data Access Object")

**Applicability:** Use the Data Access Object in any of the following situations
## Applicability
Use the Data Access Object in any of the following situations

* when you want to consolidate how the data layer is accessed
* when you want to avoid writing multiple data retrieval/persistence layers

**Credits:**
## Credits

* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
11 changes: 7 additions & 4 deletions decorator/index.md
Expand Up @@ -10,20 +10,23 @@ tags:
- Difficulty-Beginner
---

**Also known as:** Wrapper
## Also known as
Wrapper

**Intent:** Attach additional responsibilities to an object dynamically.
## Intent
Attach additional responsibilities to an object dynamically.
Decorators provide a flexible alternative to subclassing for extending
functionality.

![alt text](./etc/decorator_1.png "Decorator")

**Applicability:** Use Decorator
## Applicability
Use Decorator

* 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**
## Credits

* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
13 changes: 8 additions & 5 deletions delegation/index.md
Expand Up @@ -9,19 +9,22 @@ tags:
- Difficulty-Beginner
---

**Also known as:** Proxy Pattern
## Also known as
Proxy Pattern

**Intent:** It is a technique where an object expresses certain behavior to the outside but in
## Intent
It is a technique where an object expresses certain behavior to the outside but in
reality delegates responsibility for implementing that behaviour to an associated object.

![alt text](./etc/delegation.png "Delegate")

**Applicability:** Use the Delegate pattern in order to achieve the following
## Applicability
Use the Delegate pattern in order to achieve the following

* Reduce the coupling of methods to their class
* Components that behave identically, but realize that this situation can change in the future.

**Credits**
## Credits

* [Delegate Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Delegation_pattern)
* [Proxy Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Proxy_pattern)
* [Proxy Pattern: Wikipedia ](https://en.wikipedia.org/wiki/Proxy_pattern)

0 comments on commit 3d642cd

Please sign in to comment.