0% found this document useful (0 votes)
47 views61 pages

SOEN 344-4-Design Patterns

This document discusses several design patterns including Strategy, Prototype, Adapter, and Composite. The Strategy pattern allows algorithms to be used interchangeably by encapsulating each as an object. The Prototype pattern focuses on cloning objects to create copies. The Adapter pattern allows incompatible interfaces to work together by wrapping an existing class with a new interface. The Composite pattern allows treating individual objects and compositions in a uniform manner.

Uploaded by

nizobell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views61 pages

SOEN 344-4-Design Patterns

This document discusses several design patterns including Strategy, Prototype, Adapter, and Composite. The Strategy pattern allows algorithms to be used interchangeably by encapsulating each as an object. The Prototype pattern focuses on cloning objects to create copies. The Adapter pattern allows incompatible interfaces to work together by wrapping an existing class with a new interface. The Composite pattern allows treating individual objects and compositions in a uniform manner.

Uploaded by

nizobell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

SOEN 344

Software Architecture and Design II

Design Patterns continued

1
Design Patterns Catalog

2
5. Strategy
(Behavioral Pattern)

3
4
Using Strategy

• You have code with a lot of algorithms


• You want to use these algorithms at different times
• You have algorithm(s) that use data the client should not
know about

5
6
Intent & Example

7
Excerpt of the Structure

8
General Structure

9
Strategy - An Alternative to Subclassing

10
Example - “The Strategy Pattern” in Java AWT/Swing

11
Things to Consider

12
Things to Consider

13
Things to Consider

14
Implementation

15
Implementation

16
Comparison of the Strategy Design Pattern
and the Template Design Pattern We will come back to this
slide later when we see
Template Pattern

17
6. Prototype
(Creational Pattern)

18
19
20
21
22
23
24
25
26
27
7. Adapter
(Structural Pattern)

28
29
30
31
32
33
34
35
36
37
38
Adapter

39
40
41
8. Composite
(Structural Pattern)

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Design Patterns Catalog

61

You might also like