Design pattern
-
Upload
adel-al-ajami -
Category
Technology
-
view
264 -
download
0
description
Transcript of Design pattern
04/09/2023
2
Agenda
Mhd Adel Alajami
Understanding the need for design patterns
What are design patterns
Using design patterns
State Design Patter
Singleton Design Patter
Façade Design Patter
04/09/2023
7
the need for design patterns
Mhd Adel Alajami
Software changes
We need to add a new features - boss
There is a change in the specification -
customer
We have found a big bug – team
Flexible code
Maintainable Code
04/09/2023
8
Use Design Pattern
Mhd Adel Alajami
By learning theme
And then applying them in your OOP
designs
You will create more flexible and
maintainable code
04/09/2023
9
Dealing with change
Mhd Adel Alajami
Software has lots of ways to change
There are many design pattern to deal
with changes
Design patterns address many of the
ways software changes over time
04/09/2023
10
What are design pattern ?
Mhd Adel Alajami
Design patterns are general solutions to common problems
A pattern is a guideline for flexible and resilient code design
It does not go in detail of implementation
There is no DP for Banking system and other for games
It is a general solution for common problem in software development
04/09/2023
11
Mhd Adel Alajami
“I have a problem, when one of my
object changes , I need to let all other
objects know. Is there a good way to do
that?”
This is a common problem in software
development
There is a proven method to solve it :
The Observer Pattern
What are design pattern ?
04/09/2023
12
Where did DP come from ?
Mhd Adel Alajami
23 original pattern
Now, there are many patterns for many
different software problems
04/09/2023
13
How To Use Design Pattern
Mhd Adel Alajami
A design pattern is not a library, module
or package
It’s a guideline for how to solve a
problem
Higher level than a library
First understand the pattern, and then
use its design in your software
04/09/2023
14
Using Design Pattern
Mhd Adel Alajami
Ultimate in reuse
Build from years of software
development experience
Save times, and trial and error
Not reusing code, but reusing experience
04/09/2023
21
Disadvantage
Mhd Adel Alajami
Is not really OO at all
Any additions require many change to
code
Difficult to understand all the state and
transitions
Violates open closed principle
04/09/2023
29
Singleton Design Pattern
Mhd Adel Alajami
Prevent Creation Multi Instance
Provide Global Access
04/09/2023
36
What About Singleton With Multithreading
Mhd Adel Alajami
To Avoid creation Multi Instance in Multithreading
Initialize Static Variable
Create instance even it’s not used
Disadvantage
04/09/2023
38
Before Façade Design Pattern
Mhd Adel Alajami
Client Classes
Subsystem classes
Need to communicatewith
04/09/2023
40
Benefits
Mhd Adel Alajami
Shields clients from subsystem classes; reduces
the number of objects that clients deal with.
Promotes weak coupling between subsystem
and its clients.
Helps in layering the system. Helps eliminate
circular dependencies.
Makes using the subsystem easier