Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Design patterns
1. Presentation
on
Design Patterns
By
Samundra Shrestha
2. Patterns
Each pattern describes a problem which occurs over and
over again in our environment and then describes the core
of the solution to that problem, in such a way that you can
use this solution a million times over, without ever doing it
the same twice.
- Christopher Alexander, The
Timeless Way of Building, 1979
So what are patterns?
3. What are Patterns, really?
Patterns catalog solutions to
categories of problems
They consist of
A name
A solution to a problem
A description of the solution
An assessment of the pros and
cons of the pattern
4. What are Patterns Not?
1. An algorithm.
2. An implementation.
3. The same every time you see them.
5. Introduction to Design Patterns
Gang of Four (GOF)
Erich Gamma, Richard Helm, Ralph Johnson,
and John Vlissides
Authors of the original Design Patterns book
Problem in software design
What – business and functionality requirements
How – particular design to meet the requirements
Work – Actual implementation, How put into practice.
6. Principal and Strategies
Open Closed Principle
Dependency Inversion
Single Responsibility Policy
Why ?
improve abilities as analyst and designer.
tackle situation in which no design pattern can be
applied or design pattern has not been discovered yet.
7. Contextual Design
Open Closed Principle (OCP)
"Modules, methods, classes should be open for extension,
while closed for modifications."
Loose Coupling
Encapsulation
8. Dependency Inversion Principle
Depend on the abstractions
Higher level module should not depend on lower
level module. Both high and low level should depend
on abstractions
Abstraction should not depend on details. Details
should depend on abstractions.
10. Singleton Patterns Patterns by Examples
Problem : Ensure a class has only one instance available in the system anytime.
Output:
Design Patterns Example
11. Factory Pattern Patterns by Examples
dynamically create instances of multiple classes based on runtime input.
Output:
This is system generated
messageThis is console
generated message
12. Decorator Pattern Patterns by Examples
best suited for altering or decorating portions of an existing object’s content or
functionality without modifying the structure of the original object.
Output :
The CD contains the following tracks:
1) what-it-means. 2) brr. 3) good-bye.