SOEN 344-3a - Design Patterns
SOEN 344-3a - Design Patterns
1
Ground Rules for lectures and
Tutorial
◼ Electronic devices, such as cellular phones, text/video
messaging devices and recording devices are strictly
prohibited.
◼ Laptops are accepted only for the course purpose.
◼ The usage of any of these materials during the class
will result in you being asked to immediately leave the
class.
2
Introduction to Design Patterns
3
4
5
6
7
8
Styles
9
10
Selecting Design Patterns
(23 Design Patterns)
11
Design Patterns Catalog
12
13
Design patterns Types
◼ Creational patterns are ones that create objects for you,
rather than having you instantiate objects directly. This
gives your program more flexibility in deciding which
objects need to be created for a given case.
◼ Structural patterns help you compose groups of objects
into larger structures, such as complex user interfaces or
accounting data.
◼ Behavioral patterns help you define the
communication between objects in your system and
how the flow is controlled in a complex program.
15
Object Oriented Approaches vs
Design Patterns concepts
◼ The fundamental reason for using varies design patterns is
to keep classes separated and prevent them from having
to know too much about one another. There are a number
of strategies that OO programmers use to achieve this
separation, among them encapsulation and inheritance.
◼ Nearly all languages that have OO capabilities
support inheritance
◼ Design Patterns suggests that you always go for
➢ “Program to an interface and not to an implementation”.
➢ “Favor object composition over inheritance.”
16
17
18
simple decision making class that returns one of several
possible subclasses of an abstract base class depending on
the data that are provided.
19
20
21
22
23
24
25
26
27
28
Creational Patterns
◼ Factory Method
◼ Abstract Factory
◼ Builder
◼ Prototype
◼ Singleton
29
1. Factory Method
30
31
32
33
34
35
36
37
38
39
40
41
42
2. Abstract Factory
43
44
45
46
47
48
49
50
51
52
53
54