Skip to content

Commit 67a99ec

Browse files
committed
Conflicts: pom.xml
2 parents 2ca8ab0 + a95bd31 commit 67a99ec

File tree

9 files changed

+586
-33
lines changed

9 files changed

+586
-33
lines changed

README.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ system independent of how its objects are created, composed, and represented.
3232
* [Prototype](#prototype)
3333
* [Property](#property)
3434
* [Singleton](#singleton)
35+
* [Step Builder](#step-builder)
3536
* [Multiton](#multiton)
3637
* [Object Pool](#object-pool)
3738

@@ -206,6 +207,14 @@ access to it.
206207
**Real world examples:**
207208
* [java.lang.Runtime#getRuntime()](http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#getRuntime%28%29)
208209

210+
## <a name="step-builder">Step Builder</a> [&#8593;](#list-of-design-patterns)
211+
**Intent:** An extension of the Builder pattern that fully guides the user through the creation of the object with no chances of confusion.
212+
The user experience will be much more improved by the fact that he will only see the next step methods available, NO build method until is the right time to build the object.
213+
214+
![alt text](./step-builder/etc/step-builder.png "Step Builder")
215+
216+
**Applicability:** Use the Step 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 when in the process of constructing the order is important.
217+
209218
## <a name="adapter">Adapter</a> [&#8593;](#list-of-design-patterns)
210219
**Intent:** Convert the interface of a class into another interface the clients
211220
expect. Adapter lets classes work together that couldn't otherwise because of
@@ -307,8 +316,8 @@ are several common situations in which the Proxy pattern is applicable
307316

308317
**Typical Use Case:**
309318

310-
* Control access to another object
311-
* Lazy initialization
319+
* control access to another object
320+
* lazy initialization
312321
* implement logging
313322
* facilitate network connection
314323
* to count references to an object
@@ -334,7 +343,7 @@ improves the performance of application to great extent.
334343

335344
**Typical Use Case:**
336345

337-
* When network hits are expensive and time consuming
346+
* when network hits are expensive and time consuming
338347
* lookups of services are done quite frequently
339348
* large number of services are being used
340349

@@ -541,7 +550,7 @@ this behavior in the common parent class - it is defined once in the Servant.
541550
![alt text](./servant/etc/servant-pattern.png "Servant")
542551

543552
**Applicability:** Use the Servant pattern when
544-
* When we want some objects to perform a common action and don't want to define this action as a method in every class.
553+
* when we want some objects to perform a common action and don't want to define this action as a method in every class.
545554

546555
## <a name="null-object">Null Object</a> [&#8593;](#list-of-design-patterns)
547556
**Intent:** In most object-oriented languages, such as Java or C#, references
@@ -556,7 +565,7 @@ Object is very predictable and has no side effects: it does nothing.
556565
![alt text](./null-object/etc/null-object.png "Null Object")
557566

558567
**Applicability:** Use the Null Object pattern when
559-
* You want to avoid explicit null checks and keep the algorithm elegant and easy to read.
568+
* you want to avoid explicit null checks and keep the algorithm elegant and easy to read.
560569

561570
## <a name="event-aggregator">Event Aggregator</a> [&#8593;](#list-of-design-patterns)
562571
**Intent:** A system with lots of objects can lead to complexities when a
@@ -569,7 +578,11 @@ allowing clients to register with just the aggregator.
569578
![alt text](./event-aggregator/etc/classes.png "Event Aggregator")
570579

571580
**Applicability:** Use the Event Aggregator pattern when
572-
* Event Aggregator is a good choice when you have lots of objects that are potential event sources. Rather than have the observer deal with registering with them all, you can centralize the registration logic to the Event Aggregator. As well as simplifying registration, a Event Aggregator also simplifies the memory management issues in using observers.
581+
* Event Aggregator is a good choice when you have lots of objects that are
582+
potential event sources. Rather than have the observer deal with registering
583+
with them all, you can centralize the registration logic to the Event
584+
Aggregator. As well as simplifying registration, a Event Aggregator also
585+
simplifies the memory management issues in using observers.
573586

574587
## <a name="callback">Callback</a> [&#8593;](#list-of-design-patterns)
575588
**Intent:** Callback is a piece of executable code that is passed as an
@@ -579,7 +592,7 @@ at some convenient time.
579592
![alt text](./callback/etc/callback.png "Callback")
580593

581594
**Applicability:** Use the Callback pattern when
582-
* When some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.
595+
* when some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.
583596

584597
**Real world examples:**
585598
* [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.
@@ -604,7 +617,7 @@ only what to do with the resource.
604617
![alt text](./execute-around/etc/execute-around.png "Execute Around")
605618

606619
**Applicability:** Use the Execute Around idiom when
607-
* You use an API that requires methods to be called in pairs such as open/close or allocate/deallocate.
620+
* you use an API that requires methods to be called in pairs such as open/close or allocate/deallocate.
608621

609622
## <a name="property">Property</a> [&#8593;](#list-of-design-patterns)
610623
**Intent:** Create hierarchy of objects and new objects using already existing
@@ -667,8 +680,8 @@ order
667680
![alt text](./specification/etc/specification.png "Specification")
668681

669682
**Applicability:** Use the Specification pattern when
670-
* You need to select a subset of objects based on some criteria, and to refresh the selection at various times
671-
* You need to check that only suitable objects are used for a certain role (validation)
683+
* you need to select a subset of objects based on some criteria, and to refresh the selection at various times
684+
* you need to check that only suitable objects are used for a certain role (validation)
672685

673686
## <a name="tolerant-reader">Tolerant Reader</a> [&#8593;](#list-of-design-patterns)
674687
**Intent:** Tolerant Reader is an integration pattern that helps creating
@@ -679,7 +692,7 @@ changes, the readers must not break.
679692
![alt text](./tolerant-reader/etc/tolerant-reader.png "Tolerant Reader")
680693

681694
**Applicability:** Use the Tolerant Reader pattern when
682-
* The communication schema can evolve and change and yet the receiving side should not break
695+
* the communication schema can evolve and change and yet the receiving side should not break
683696

684697
## <a name="model-view-controller">Model-View-Controller</a> [&#8593;](#list-of-design-patterns)
685698
**Intent:** Separate the user interface into three interconnected components:
@@ -701,7 +714,7 @@ logic, which updates all of the views that are affected.
701714
![alt text](./flux/etc/flux.png "Flux")
702715

703716
**Applicability:** Use the Flux pattern when
704-
* You want to focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.
717+
* you want to focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.
705718

706719
## <a name="double-dispatch">Double Dispatch</a> [&#8593;](#list-of-design-patterns)
707720
**Intent:** Double Dispatch pattern is a way to create maintainable dynamic
@@ -710,7 +723,7 @@ behavior based on receiver and parameter types.
710723
![alt text](./double-dispatch/etc/double-dispatch.png "Double Dispatch")
711724

712725
**Applicability:** Use the Double Dispatch pattern when
713-
* The dynamic behavior is not defined only based on receiving object's type but also on the receiving method's parameter type.
726+
* the dynamic behavior is not defined only based on receiving object's type but also on the receiving method's parameter type.
714727

715728
**Real world examples:**
716729
* [ObjectOutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/ObjectOutputStream.html)
@@ -742,7 +755,7 @@ and eliminating the latency of creating new threads.
742755
![alt text](./thread-pool/etc/thread-pool.png "Thread Pool")
743756

744757
**Applicability:** Use the Thread Pool pattern when
745-
* You have a large number of short-lived tasks to be executed in parallel
758+
* you have a large number of short-lived tasks to be executed in parallel
746759

747760
## <a name="async-method-invocation">Async Method Invocation</a> [&#8593;](#list-of-design-patterns)
748761
**Intent:** Asynchronous method invocation is pattern where the calling thread
@@ -753,9 +766,10 @@ callbacks or waiting until everything is done.
753766
![alt text](./async-method-invocation/etc/async-method-invocation.png "Async Method Invocation")
754767

755768
**Applicability:** Use async method invocation pattern when
756-
* You have multiple independent tasks that can run in parallel
757-
* You need to improve performance of running a group of sequential tasks
758-
* You have limited number of processing capacity or long running tasks and the caller cannot wait the tasks to be ready
769+
* you have multiple independent tasks that can run in parallel
770+
* you need to improve the performance of a group of sequential tasks
771+
* you have limited amount of processing capacity or long running tasks and the
772+
caller should not wait the tasks to be ready
759773

760774
**Real world examples:**
761775
* [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)
@@ -769,7 +783,7 @@ attributes by encapsulating them in single Data object.
769783
![alt text](./private-class-data/etc/private-class-data.png "Private Class Data")
770784

771785
**Applicability:** Use the Private Class Data pattern when
772-
* You want to prevent write access to class data members
786+
* you want to prevent write access to class data members
773787

774788
## <a name="object-pool">Object Pool</a> [&#8593;](#list-of-design-patterns)
775789
**Intent:** When objects are expensive to create and they are needed only for
@@ -780,8 +794,8 @@ are in use and which are available.
780794
![alt text](./object-pool/etc/object-pool.png "Object Pool")
781795

782796
**Applicability:** Use the Object Pool pattern when
783-
* The objects are expensive to create (allocation cost)
784-
* You need a large number of short-lived objects (memory fragmentation)
797+
* the objects are expensive to create (allocation cost)
798+
* you need a large number of short-lived objects (memory fragmentation)
785799

786800
## <a name="dependency-injection">Dependency Injection</a> [&#8593;](#list-of-design-patterns)
787801
**Intent:** Dependency Injection is a software design pattern in which one or
@@ -794,8 +808,8 @@ inversion of control and single responsibility principles.
794808
![alt text](./dependency-injection/etc/dependency-injection.png "Dependency Injection")
795809

796810
**Applicability:** Use the Dependency Injection pattern when
797-
* When you need to remove knowledge of concrete implementation from object
798-
* To enable unit testing of classes in isolation using mock objects or stubs
811+
* when you need to remove knowledge of concrete implementation from object
812+
* to enable unit testing of classes in isolation using mock objects or stubs
799813

800814
## <a name="naked-objects">Naked Objects</a> [&#8593;](#list-of-design-patterns)
801815
**Intent:** The Naked Objects architectural pattern is well suited for rapid
@@ -805,9 +819,9 @@ everything else is autogenerated by the framework.
805819
![alt text](./naked-objects/etc/naked-objects.png "Naked Objects")
806820

807821
**Applicability:** Use the Naked Objects pattern when
808-
* You are prototyping and need fast development cycle
809-
* An autogenerated user interface is good enough
810-
* You want to automatically publish the domain as REST services
822+
* you are prototyping and need fast development cycle
823+
* an autogenerated user interface is good enough
824+
* you want to automatically publish the domain as REST services
811825

812826
**Real world examples:**
813827
* [Apache Isis](https://isis.apache.org/)
@@ -866,11 +880,11 @@ degrading execution efficiency.
866880
![Half-Sync/Half-Async class diagram](./half-sync-half-async/etc/half-sync-half-async.png)
867881

868882
**Applicability:** Use Half-Sync/Half-Async pattern when
869-
* A system possesses following characteristics:
870-
* System must perform tasks in response to external events that occur asynchronously, like hardware interrupts in OS
871-
* It is inefficient to dedicate separate thread of control to perform synchronous I/O for each external source of event
872-
* The higher level tasks in the system can be simplified significantly if I/O is performed synchronously.
873-
* One or more tasks in a system must run in a single thread of control, while other tasks may benefit from multi-threading.
883+
* a system possesses following characteristics:
884+
* the system must perform tasks in response to external events that occur asynchronously, like hardware interrupts in OS
885+
* it is inefficient to dedicate separate thread of control to perform synchronous I/O for each external source of event
886+
* the higher level tasks in the system can be simplified significantly if I/O is performed synchronously.
887+
* one or more tasks in a system must run in a single thread of control, while other tasks may benefit from multi-threading.
874888

875889
**Real world examples:**
876890
* [BSD Unix networking subsystem](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
@@ -941,9 +955,13 @@ Flyweight.
941955

942956
**To work on a new pattern** you need to do the following steps:
943957

944-
1. If there is no issue for the new pattern yet, raise new issue. Comment on the issue that you are working on it so that others don't start work on the same thing.
958+
1. If there is no issue for the new pattern yet, raise new issue. Comment on
959+
the issue that you are working on it so that others don't start work on the
960+
same thing.
945961
2. Fork the repository.
946-
3. Implement the code changes in your fork. Remember to add sufficient comments documenting the implementation. Reference the issue id e.g. #52 in your commit messages.
962+
3. Implement the code changes in your fork. Remember to add sufficient comments
963+
documenting the implementation. Reference the issue id e.g. #52 in your
964+
commit messages.
947965
4. Create a simple class diagram from your example code.
948966
5. Add description of the pattern in README.md and link to the class diagram.
949967
6. Create a pull request.
@@ -953,7 +971,9 @@ Flyweight.
953971
1. Check that the issue has "help wanted" badge
954972
2. Comment on the issue that you are working on it
955973
3. Fork the repository.
956-
4. Implement the code changes in your fork. Remember to add sufficient comments documenting the implementation. Reference the issue id e.g. #52 in your commit messages.
974+
4. Implement the code changes in your fork. Remember to add sufficient comments
975+
documenting the implementation. Reference the issue id e.g. #52 in your
976+
commit messages.
957977
5. Create a pull request.
958978

959979
**For creating/editing UML diagrams** you need [ObjectAid UML Explorer for Eclipse](http://www.objectaid.com/home).
@@ -997,6 +1017,7 @@ other words, version numbers are used only for project planning sake.
9971017
* [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
9981018
* [Spring Data](http://www.amazon.com/Spring-Data-Mark-Pollack/dp/1449323952/ref=sr_1_1)
9991019
* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
1020+
* [Marco Castigliego - Step Builder](http://rdafbn.blogspot.co.uk/2012/07/step-builder-pattern_28.html)
10001021

10011022

10021023
# License

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<module>async-method-invocation</module>
7474
<module>business-delegate</module>
7575
<module>half-sync-half-async</module>
76+
<module>step-builder</module>
7677
<module>layers</module>
7778
</modules>
7879

step-builder/etc/step-builder.png

74.3 KB
Loading

0 commit comments

Comments
 (0)