SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler

SOEN 343
Software Design
Section H Fall 2006
Dr Greg Butler
http://www.cs.concordia.ca/~gregb/home/soen343h-f06.html
Course Introduction
•
•
•
•
•
•
•
•
Course People
Course Components
What the course is
What the course is not
Enterprise Application (Assignments)
Larman’s Design Process
What is OO Analysis and Design
Design Pattern Example - Command
Course People – Section H
Instructor: Dr Greg Butler
Office Hours: Wednesdays 15:00 to 16:00
Or by appointment
But ask questions in class please
TAs: Asif Dogar & Rajiv Abraham
Course Coordinator: Dr Patrice Chalin
Course Components
Lectures: WF 13:15 to 14:30 CL-220
Tutorials: F 14:45 to 15:35
In Lab to be announced; start week 2
Assignments: 3-4, every 2 weeks, start week 8,
worth 5-15%
Midterm Exam: week 7, worth 25-35%
Quizzes: 2-3, approx. weeks 4, 10,.. worth 5-10%
Final Exam: worth 50-60%; you must pass final
Basic Questions (Let’s Discuss)
What is software design?
How is it different from software programming?
Software development?
How do we design software?
What is the role of objects, layers, architecture, ..?
What is the role of tests, responsibilities, patterns,
models, …?
How does design fit into the software lifecycle?
What is good design?
How does software design differ from … design?
Course Objectives
• “Think in Objects”
• Practice
• Analyze requirements with • Apply agile modeling
use cases
• Design object solutions
• Create domain models
– Assign responsibilities to
objects
• Apply an iterative & agile
Unified Process (UP)
• Relate analysis and
design artifacts
• Read & write highfrequency UML
– Design collaborations
– Design with patterns
– Design with architectural
layers
– Understand OOP (e.g.,
Java) mapping issues
What the course is:
A (first) look at OO design!
Design process: domain model, use cases,
design
Emphasis: models, GRASP principles,
design patterns, responsibility,
collaboration
Mentions: RDD, TDD, MDD, extensibility
Closely follows textbook!
What the course is not:
A course in UML, Java
• You should know the basics of these
• And become expert (as needed) yourself
A course in tools: Eclipse, XDE, JUnit
• You can work through tutorials yourself
A course in UI design, DB design
A course in software engineering, software
architecture, software reuse, …
Lectures
Review of Java and object-oriented programming
Responsibility Driven Design following Larman
• Each object has responsibility (ies)
• GRASP principles for distribution of responsibilities
• GoF design patterns
• Application of principles and patterns to examples/assignments
Domain Modeling
Introduction to Enterprise Applications
• Fowler’s patterns
• Application of GRASP principles in Fowler’s patterns
• Application in assignments
Transition from requirements to design following Larman
Enterprise Applications Patterns
Assignments (and some lectures) are about
building web-based systems for
enterprise applications
Involve
Presentation on the web
Business Logic and Business Objects
Data storage and access
use book of Martin Fowler, “Patterns of
Enterprise Application Architecture”
Data Source Domain Presentation
Fowler’s EA Patterns
Page Controller
Template View
Front Controller
Transform View
Transaction Script
Active Record
Domain Model
Table Module
Data Mapper
Row Data Gateway
Table Data Gateway
Larman’s Design Process
Sample UP Artifact Relationships
Domain Model
Sale
Business
Modeling
Sales
LineItem
1..*
1
date
...
...
...
quantity
Use-Case Model
Process Sale
Process
Sale
use
case
names
Cashier
Requirements
Use Case Diagram
starting events to
design for, and
detailed postcondition to
satisfy
Design
non-functional
requirements
functional
requirements
that must be
realized by
the objects
Use Case Text
system
events
ideas for
the postconditions
inspiration for
names of
some
software
domain
objects
Supplementary
Specification
1. Customer
arrives ...
2. ...
3. Cashier
enters item
identifier.
domain rules
: System
Glossary
Operation:
enterItem(…)
Post-conditions:
-...
: Cashier
system
operations
make
NewSale()
enterItem
(id, quantity)
item details,
formats,
validation
System Sequence Diagrams
Operation Contracts
Design Model
: Register
: ProductCatalog
enterItem
(itemID, quantity)
d = getProductDescription(itemID)
addLineItem( d, quantity )
Register
ProductCatalog
...
makeNewSale()
enterItem(...)
...
...
*
1
getProductDescription(...)
...
: Sale
Domain Model
Pays-for-overdue-charges 
VideoRental
CashPayment
Pays-for 
amount : Money
1
1
date
1
1
1
*
dueDate
returnDate
returnTime
1..*
*
Initiates 
1
0..1
RentalTransaction
Records-rental-of 
1
Rents
1..*
Customer
VideoStore
Rents-from  address
name
1
phoneNumber
address
name
phoneNumber
1
*
1
1
Maintains
Has 
Video
Stocks
*
ID
*
1
Owns-a 
1
1
*
Membership
Catalog
ID
startDate
1
Described-by 
1
1..*
VideoDescription
LoanPolicy
1
Defines
perDayRentalCharge
perDayLateCharge
1..*
1
1..*
1
title
subjectCategory
Determines-rental-charge 
*
Use Case Model
Partial artifacts, refined in each iteration.
Use-Case Model
:System
foo( x )
Requirements
bar( y )
text
use
cases
use
case
diagrams
system
sequence
diagrams
system
operations
system
operation
contracts
Typical Software Architecture Layers
handles presentation layer requests
workflow
session state
window/page transitions
consolidation/transformation of disparate
data for presentation
handles application layer requests
implementation of domain rules
domain services (POS, Inventory)
- services may be used by just one
application, but there is also the possibility
of multi-application services
very general low-level business services
used in many business domains
CurrencyConverter
(relatively) high-level technical services
and frameworks
Persistence, Security
low-level technical services, utilities,
and frameworks
data structures, threads, math,
file, DB, and network I/O
UI
(AKA Presentation, View)
more
app
specific
Application
(AKA Workflow, Process,
Mediation, App Controller)
dependency
GUI windows
reports
speech interface
HTML, XML, XSLT, JSP, Javascript, ...
Domain
(AKA Business,
Application Logic, Model)
Business Infrastructure
(AKA Low-level Business Services)
Technical Services
(AKA Technical Infrastructure,
High-level Technical Services)
Foundation
(AKA Core Services, Base Services,
Low-level Technical Services/Infrastructure)
width implies range of applicability
Typical Software Architecture Layers (Simplified)
UI
Swing
not the Java
Swing libraries, but
our GUI classes
based on Swing
Web
Domain
Sales
Payments
Taxes
Logging
RulesEngine
Technical Services
Persistence
What is Design?
Developing a blueprint (plan) for a
mechanism that performs the required
task,
… taking into account all the constraints, &
… making trade-offs between constraints
when they are in conflict.
What is OO Analysis and Design
• Object-Oriented
Analysis
• Object-Oriented
Design
– Important domain
concepts or objects?
– Design of software
objects
– Vocabulary?
– Responsibilities
– Collaborations
– Visualized in the UP
Domain Model
– Design patterns
– Visualized in the UP
Design Model
Important Concepts
Model
• Abstraction hiding (unimportant) details
• Eg, cover of Larman’s book
GRASP Principle
• for assigning responsibility
Design pattern
• Solution to design problem in context
• Eg, Command pattern
Responsibility-Driven Design (RDD)
• Detailed object design is usually done
from the point of view of the metaphor of:
– Objects have responsibilities
– Objects collaborate
• Responsibilities are an abstraction.
– The responsibility for persistence.
• Large-grained responsibility.
– The responsibility for the sales tax calculation.
• More fine-grained responsibility.
The 9 GRASP Principles
1.
2.
3.
4.
5.
6.
7.
8.
9.
Creator
Expert
Controller
Low Coupling
High Cohesion
Polymorphism
Pure Fabrication
Indirection
Protected Variations
Overview of Patterns
•Present solutions
to common
software problems
arising within a
certain context
•Help resolve
key software
design
forces
•Capture recurring structures &
dynamics among software
participants to facilitate reuse of
successful designs
•Generally codify expert
knowledge of design strategies,
constraints & “best practices”
AbstractService
service
Client
Proxy
service
Service
1
1
service
The Proxy Pattern
•Flexibility
•Extensibility
•Dependability
•Predictability
•Scalability
•Efficiency
Command Pattern
Problem: How to allow the same command
to be invoked by
– Menu selection
– Alt-ctrl shortcut
– Commandline text entry, etc
• How to allow (unlimited) undo/redo
• How to keep a log/audit/history of
commands invoked
• How to allow “macro” commands to be
defined
Command Pattern
• You have commands that need to be
– executed,
– undone, or
– queued
• Command design pattern separates
– Receiver from Invoker from Commands
• All commands derive from Command and
implement do(), undo(), and redo()
• Also allows recording history, replay