Lecture 05
Lecture 05
Architecture
WEEK 7
STRUCTURAL PATTERN
COURSE INSTRUCTOR:
TAZZAINA MALIK
1
Adapter Pattern
STRUCTURAL PAT TERN
2
Daily life example-I
3
Daily life example-II
4
Daily life example-III
5
Concept Behind:
6
Class Diagram:
7
Example:
8
Concept Behind:
9
Class Diagram:
10
Sequence Diagram:
11
Code
Walkthrough
ADAPTER PAT TERN
12
Example-I
13
14
15
When to use?
▪ Need to work with incompatible classes
▪ Need to work with new and legacy
systems
▪ Tool kits or class libraries
incompatibility
16
Summary:
▪Falls under structural pattern
▪Works as a bridge
▪Adapting between classes/objects
▪Also known as wrapper pattern
▪Three main component: adapter,
target and adaptee classes
17
Facade Pattern
STRUCTURAL PAT TERN
18
Real World Example-I
19
Real World Example-II
20
Real World Example-III
21
Real World Example-V
22
Example:
23
Example:
24
Example:
25
Why Façade?
26
Class Diagram
27
Class Diagram:
28
Complex Frameworks or Libraries
29
Complex Frameworks or Libraries
30
Code
Walkthrough
FAÇADE PAT TERN
31
Class Diagram
32
33
34
35
Many classes
many
method calls
36
Apply Façade
37
38
39
Where to use Façade ?
We can integrate the facade pattern in the
following design problems:
1. SRP->the subsystems evolve, they become
increasingly more complex
2. When there are lots of dependencies between
the client and concrete implementation
3. facade can provide the entry point
40
Command Pattern
BEHAVIORAL PAT TERN
41
Real-Life Example:
42
Sequence Diagram:
43
Why we need it?
44
How Does Command Design Pattern Work?
45
Intent Behind:
46
Problem:
Text Editor Application
- Toolbar with buttons
(operation)
- Button Class
- Each Button- Different
Things
- Code for click handlers?
All buttons of the app are derived from the same class.
47
Solution-I:
48
Solution: Separation of Concern
49
Solution: Separation of Concern
50
Structure:
51
How to Implement?
52
Any Questions?
53