1. Design Patterns
Factory Method Pattern
Singleton Pattern
Observer Pattern
- By – Md. Nadimozzaman Pappo
- ID - 132014031
6/6/2016Depertment of Computer Science & Engineering
1
2. What is Design Patterns?
Solution to a commonly occurring problem
Repeatable -> Pattern
Template for how to solve a problem
Best practice – Designers & Developers
Create strong architecture
6/6/2016Depertment of Computer Science & Engineering
2
3. Some Popular Design Patterns
Factory Method Pattern
Abstract Factory Pattern
Singleton Pattern
Decorator Pattern
Adapter Pattern
Observer Pattern
MVC Pattern
CQRS Pattern
….And so many
6/6/2016Depertment of Computer Science & Engineering
3
4. Factory Method Pattern
Create object without exposing the creation logic
A common interface
Product(concrete) classes
Factory(concrete)
Best way to create object(1-n)
6/6/2016Depertment of Computer Science & Engineering
4
5. Factory Method Pattern – Class Diagram
6/6/2016Depertment of Computer Science & Engineering
5
7. Singleton Pattern
On one class-
Ensure only one object gets created
Private constructor
Access the object without instantiate
Provides a static method to access outside
6/6/2016Depertment of Computer Science & Engineering
7
8. Singleton Pattern – Class Diagram
6/6/2016Depertment of Computer Science & Engineering
8
10. Observer Pattern
A way of notifying change to a number of classes
Define a one-to-many dependency
Three actor classes - Subject, Observer and Client
Node.js – Callback, Event Loop, Event Emitter
Asynchronous execution – Like AJAX
6/6/2016Depertment of Computer Science & Engineering
10
11. Observer Pattern – Class Diagram
6/6/2016Depertment of Computer Science & Engineering
11