#design-
patterns
,Table of Contents
About 1
Chapter 1: Getting started with Design patterns 2
Remarks 2
Examples 2
Introduction 2
Chapter 2: Adapter 4
Examples 4
Adapter Pattern (PHP) 4
Adapter (Java) 4
Java Example 5
Adapter (UML & example situation) 6
Chapter 3: blackboard 11
Examples 11
C# Sample 11
Chapter 4: Bridge Pattern 15
Examples 15
Bridge pattern implementation in java 15
Chapter 5: Builder Pattern 18
Remarks 18
Examples 18
Builder Pattern / C# / Fluent Interrface 18
Builder Pattern / Java Implementation 19
Builder pattern in Java with composition 21
Java / Lombok 24
Advanced Builder Pattern With Java 8 Lambda Expression 25
Chapter 6: Chain of Responsibility 28
Examples 28
Chain of Responsibility example (Php) 28
Chapter 7: Command pattern 30
Examples 30
, Command pattern example in Java 30
Chapter 8: Composite pattern 33
Examples 33
Composite logger 33
Chapter 9: Composite pattern 35
Introduction 35
Remarks 35
Examples 35
pseudocode for a dumb file manager 35
Chapter 10: Data Access Object(DAO) design pattern 37
Examples 37
Data Access Object J2EE design pattern with Java 37
Chapter 11: Decorator pattern 40
Introduction 40
Parameters 40
Examples 40
VendingMachineDecorator 40
Caching Decorator 44
Chapter 12: Dependency Injection 46
Introduction 46
Remarks 46
Examples 47
Setter injection (C#) 47
Constructor Injection (C#) 47
Chapter 13: Facade 49
Examples 49
Real world facade (C#) 49
Facade example in java 49
Chapter 14: Factory 53
Remarks 53
Examples 53
, Simple factory (Java) 53
Abstract factory (C++) 54
Simple example of Factory that uses an IoC (C#) 56
An Abstract Factory 58
Factory example by implementing Factory method (Java) 59
Flyweight Factory (C#) 63
Factory method 64
Chapter 15: Iterator Pattern 65
Examples 65
The Iterator Pattern 65
Chapter 16: lazy loading 67
Introduction 67
Examples 67
JAVA lazy loading 67
Chapter 17: Mediator Pattern 69
Examples 69
Mediator pattern example in java 69
Chapter 18: Monostate 72
Remarks 72
Examples 72
The Monostate Pattern 72
Monostate-based hierarchies 73
Chapter 19: Multiton 75
Remarks 75
Examples 75
Pool of Singletons (PHP example) 75
Registry of Singletons (PHP example) 76
Chapter 20: MVC, MVVM, MVP 78
Remarks 78
Examples 78
Model View Controller (MVC) 78
Model View ViewModel (MVVM) 79