Pattern Oriented Design: Design Patterns Explained
Download Pattern Oriented Design: Design Patterns Explained
Preview text
CSC 335: Object-Oriented Programming and Design
Pattern-Oriented Design
by Rick Mercer based on the GoF book and
Design Patterns Explained A New Perspective on Object-Oriented Design Alan Shalloway, James R. Trott Addison Wesley ISBN 0-201-71594-5
1
Using Patterns to Design
There are 23 Object-Oriented design patterns cataloged in the GoF book--we’ve considered 10 so far (Fall 09)
Iterator, Observer, Strategy, Composite, Singleton, Flyweight, Command, Template, Chain of Responsibility, Decorator
We'll use some patterns to help design a system
The new case study is in electronic retailing over the internet (An Ecommerce system) Several design decisions will be aided by knowledge of existing design patterns
at a fairly high level of abstraction
2
Plan too much, plan ahead, or don’t plan at all?
Development of software systems can suffer from analysis paralysis: attempt to consider all possible changes in the future
At other times developers jump to code too quickly
there is tremendous pressure to deliver, not maintain
Life’s three certainties for software developers
Death, Taxes, and Changes in Requirements
There is a middle ground for planning for change
3
How will change occur
First, anticipate that changes will occur Consider where they will change, rather than the
exact nature of the changes These issues will come up in the Ecommerce case
study
4
What is variable in the design?
Consider what is variable in your design
Instead of focusing on what might force a change to your design
Consider what you might want to change Encapsulate the concept that varies
– this is a theme of many design patterns
Hopefully there are long term benefits without a lot of extra work up front
5
OO Design Patterns Used
In the upcoming case study, these design patterns will help make for a system that is good design
Strategy Singleton Decorator Observer
We've considered all four
6
An Ecommerce System
There is a TaskController object that handles sales requests over the internet
When the sales order is requested, the controller delegates to a SalesOrder object
7
Assign Responsibilities
SalesOrder responsibilities:
Allow users to make an order using GUI input Process the order Print a sales receipt
TaskController
SalesOrder +calcTax():double
SalesTicketPrinter
8
Changing Requirements
Start charging taxes on order from customers
need to add rules for taxation, but how?
modify existing SalesOrder to handle U.S. taxes extend the existing SalesOrder object and modify the tax rules so it applies to the new country
This is an inheritance solution
9
Subclassing Solution
TaskController
US Tax Rules Canadian Tax Rules
SalesOrder
+calcTax():double
SalesTicketPrinter
CanadianSalesOrder
+calcTax():double
10
Pattern-Oriented Design
by Rick Mercer based on the GoF book and
Design Patterns Explained A New Perspective on Object-Oriented Design Alan Shalloway, James R. Trott Addison Wesley ISBN 0-201-71594-5
1
Using Patterns to Design
There are 23 Object-Oriented design patterns cataloged in the GoF book--we’ve considered 10 so far (Fall 09)
Iterator, Observer, Strategy, Composite, Singleton, Flyweight, Command, Template, Chain of Responsibility, Decorator
We'll use some patterns to help design a system
The new case study is in electronic retailing over the internet (An Ecommerce system) Several design decisions will be aided by knowledge of existing design patterns
at a fairly high level of abstraction
2
Plan too much, plan ahead, or don’t plan at all?
Development of software systems can suffer from analysis paralysis: attempt to consider all possible changes in the future
At other times developers jump to code too quickly
there is tremendous pressure to deliver, not maintain
Life’s three certainties for software developers
Death, Taxes, and Changes in Requirements
There is a middle ground for planning for change
3
How will change occur
First, anticipate that changes will occur Consider where they will change, rather than the
exact nature of the changes These issues will come up in the Ecommerce case
study
4
What is variable in the design?
Consider what is variable in your design
Instead of focusing on what might force a change to your design
Consider what you might want to change Encapsulate the concept that varies
– this is a theme of many design patterns
Hopefully there are long term benefits without a lot of extra work up front
5
OO Design Patterns Used
In the upcoming case study, these design patterns will help make for a system that is good design
Strategy Singleton Decorator Observer
We've considered all four
6
An Ecommerce System
There is a TaskController object that handles sales requests over the internet
When the sales order is requested, the controller delegates to a SalesOrder object
7
Assign Responsibilities
SalesOrder responsibilities:
Allow users to make an order using GUI input Process the order Print a sales receipt
TaskController
SalesOrder +calcTax():double
SalesTicketPrinter
8
Changing Requirements
Start charging taxes on order from customers
need to add rules for taxation, but how?
modify existing SalesOrder to handle U.S. taxes extend the existing SalesOrder object and modify the tax rules so it applies to the new country
This is an inheritance solution
9
Subclassing Solution
TaskController
US Tax Rules Canadian Tax Rules
SalesOrder
+calcTax():double
SalesTicketPrinter
CanadianSalesOrder
+calcTax():double
10
Categories
You my also like
The GoF Design Patterns Reference
6.3 MB57.1K17.1K2020 Oregon Public Finance: Basic Facts
3.2 MB8.7K2.6KPayroll Tax Withholding Deferral Memo and FAQs
121.7 KB38.9K19.4KSignificant Features of Fiscal Federalism 1995 Edition
7.8 MB16.7K2.2KTo: From: Date: Re: Federal Tax Deposit Requirements
104.6 KB11.3K1.1K2020 Schedule A (Form 1040)
95.5 KB10.8K2.3KVillage of Lac La Bel
911.4 KB11.3K1.7KCoffee Shop Menu
1.3 MB11.7K3.4KReal Property Tax General Information
58.9 KB3.8K1.1K