Skip to content

Commit d7526fc

Browse files
committed
iluwatar#354 Add maven model for feature toggle design pattern
1 parent cf10bd1 commit d7526fc

File tree

86 files changed

+1165
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1165
-270
lines changed

abstract-factory/index.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@ tags:
1010
- Difficulty-Intermediate
1111
---
1212

13-
**Also known as:** Kit
13+
## Also known as
14+
Kit
1415

15-
**Intent:** Provide an interface for creating families of related or dependent
16+
## Intent
17+
Provide an interface for creating families of related or dependent
1618
objects without specifying their concrete classes.
1719

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

20-
**Applicability:** Use the Abstract Factory pattern when
22+
## Applicability
23+
Use the Abstract Factory pattern when
2124

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

27-
**Real world examples:**
30+
## Real world examples
2831

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

31-
**Credits**
34+
## Credits
3235

3336
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

adapter/index.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@ tags:
1010
- Difficulty-Beginner
1111
---
1212

13-
**Also known as:** Wrapper
13+
## Also known as
14+
Wrapper
1415

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
1618
expect. Adapter lets classes work together that couldn't otherwise because of
1719
incompatible interfaces.
1820

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

21-
**Applicability:** Use the Adapter pattern when
23+
## Applicability
24+
Use the Adapter pattern when
2225

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

27-
**Real world examples:**
30+
## Real world examples
2831

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

31-
**Credits**
34+
## Credits
3235

3336
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

async-method-invocation/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,23 @@ tags:
1010
- Functional
1111
---
1212

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

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

20-
**Applicability:** Use async method invocation pattern when
21+
## Applicability
22+
Use async method invocation pattern when
2123

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

27-
**Real world examples:**
29+
## Real world examples
2830

2931
* [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)
3032
* [Task-based Asynchronous Pattern](https://msdn.microsoft.com/en-us/library/hh873175.aspx) (.NET)

bridge/index.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@ tags:
1010
- Difficulty-Intermediate
1111
---
1212

13-
**Also known as:** Handle/Body
13+
## Also known as
14+
Handle/Body
1415

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
1618
vary independently.
1719

18-
1920
![alt text](./etc/bridge.png "Bridge")
2021

21-
**Applicability:** Use the Bridge pattern when
22+
## Applicability
23+
Use the Bridge pattern when
2224

2325
* 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.
2426
* 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
2527
* changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have to be recompiled.
2628
* 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
2729
* 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.
2830

29-
**Credits**
31+
## Credits
3032

3133
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

builder/index.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@ tags:
1010
- Difficulty-Intermediate
1111
---
1212

13-
**Intent:** Separate the construction of a complex object from its
13+
## Intent
14+
Separate the construction of a complex object from its
1415
representation so that the same construction process can create different
1516
representations.
1617

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

19-
**Applicability:** Use the Builder pattern when
20+
## Applicability
21+
Use the Builder pattern when
2022

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

24-
**Real world examples:**
26+
## Real world examples
2527

2628
* [java.lang.StringBuilder](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
2729
* [Apache Camel builders](https://github.com/apache/camel/tree/0e195428ee04531be27a0b659005e3aa8d159d23/camel-core/src/main/java/org/apache/camel/builder)
2830

29-
**Credits**
31+
## Credits
3032

3133
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

business-delegate/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ tags:
99
- Difficulty-Intermediate
1010
---
1111

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

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

19-
**Applicability:** Use the Business Delegate pattern when
20+
## Applicability
21+
Use the Business Delegate pattern when
2022

2123
* you want loose coupling between presentation and business tiers
2224
* you want to orchestrate calls to multiple business services

caching/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ tags:
1010
- Performance
1111
---
1212

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

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

19-
**Applicability:** Use the Caching pattern(s) when
20+
## Applicability
21+
Use the Caching pattern(s) when
2022

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

23-
**Credits**
25+
## Credits
2426

2527
* [Write-through, write-around, write-back: Cache explained](http://www.computerweekly.com/feature/Write-through-write-around-write-back-Cache-explained)
2628
* [Read-Through, Write-Through, Write-Behind, and Refresh-Ahead Caching](https://docs.oracle.com/cd/E15357_01/coh.360/e15723/cache_rtwtwbra.htm#COHDG5177)

callback/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ tags:
1111
- Idiom
1212
---
1313

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
1516
argument to other code, which is expected to call back (execute) the argument
1617
at some convenient time.
1718

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

20-
**Applicability:** Use the Callback pattern when
21+
## Applicability
22+
Use the Callback pattern when
2123

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

24-
**Real world examples:**
26+
## Real world examples
2527

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

chain/index.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,25 @@ tags:
1010
- Difficulty-Intermediate
1111
---
1212

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

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

19-
**Applicability:** Use Chain of Responsibility when
20+
## Applicability
21+
Use Chain of Responsibility when
2022

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

25-
**Real world examples:**
27+
## Real world examples
2628

2729
* [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)
2830
* [Apache Commons Chain](https://commons.apache.org/proper/commons-chain/index.html)
2931

30-
**Credits**
32+
## Credits
3133

3234
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

command/index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,35 @@ tags:
1010
- Difficulty-Intermediate
1111
---
1212

13-
**Also known as:** Action, Transaction
13+
## Also known as
14+
Action, Transaction
1415

15-
**Intent:** Encapsulate a request as an object, thereby letting you
16+
## Intent
17+
Encapsulate a request as an object, thereby letting you
1618
parameterize clients with different requests, queue or log requests, and
1719
support undoable operations.
1820

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

21-
**Applicability:** Use the Command pattern when you want to
23+
## Applicability
24+
Use the Command pattern when you want to
2225

2326
* 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.
2427
* 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
2528
* 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
2629
* 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
2730
* 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
2831

29-
**Typical Use Case:**
32+
## Typical Use Case
3033

3134
* to keep a history of requests
3235
* implement callback functionality
3336
* implement the undo functionality
3437

35-
**Real world examples:**
38+
## Real world examples
3639

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

39-
**Credits**
42+
## Credits
4043

4144
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

0 commit comments

Comments
 (0)