CSC 413 - Software Development 5. Strategy Design Pattern: 2/3/18 John Roberts
CSC 413 - Software Development 5. Strategy Design Pattern: 2/3/18 John Roberts
2/3/18
John Roberts
2
Overview
• SOLID
3
SOLID
3
4
Single Responsibility Principle
6
Liskov Substitution Principle
6
7
Interface Segregation Principle
• Depend on abstractions, not concretions In bad example, can’t easily replace worker with different type of worker
• High level modules should not depend on low level In good example, both high level (Manager) and low level (Worker and
modules - both should depend on abstractions
SuperWorker) depend on abstraction, easy to swap
• Abstractions should not depend on details. Details
should depend on abstractions.
• Github: Lecture 5
9
Overview
• SOLID
9
10 Much of this taken from wiki and the Gang of 4 book
Strategy Design Pattern
10
11
Open/Closed Principle
11
12
Open/Closed Principle
12
13 Where have we seen this pattern before?
Liskov Substitution Principle
13
14
Operator class
Operator
AdditionOperator MultiplicationOperator
evaluate( … ) evaluate( … ) 14
15
References
15