Systems Analysis and Design Allen Dennis and

Download Report

Transcript Systems Analysis and Design Allen Dennis and

Systems Analysis and
Design
Alan Dennis, Barbara Wixom, and David
Tegarden
John Wiley & Sons, Inc.
Slides by Fred Niederman
Slide 1
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Copyright © 2001
John Wiley & Sons, Inc.
All rights reserved. Reproduction or translation of this
work beyond that permitted in Section 117 of the 1976
United States Copyright Act without the express written
permission of the copyright owner is unlawful.
Request for further information should be addressed to
the Permissions Department, John Wiley & Sons, Inc.
The purchaser may make back-up copies for his/her own
use only and not for redistribution or resale.
The Publisher assumes no responsibility for errors,
omissions, or damages, caused by the use of these
programs or from the use of the information contained
herein.
Slide 2
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Class and Method Design
Chapter 14
Slide 3
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Key Concepts
Low-level or detailed design is
critical despite libraries and
components
Pre-existing classes need to be
understood and organized
Some, if not all code, is generally
still needed to instantiate new
classes
Slide 4
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
REVISITING THE BASIC
CHARACTERISTICS OF
OBJECT-ORIENTATION
Slide 5
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Elements
Classes
Objects
Attributes
States
Methods
Messages
Slide 6
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Encapsulation
Hiding the content of the object
from outside view
Communication only through
object’s methods
Key to reusability
Slide 7
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Polymorphism
Same message triggers different
methods in different objects
Dynamic binding means specific method
is selected at run time
Implementation of dynamic binding is
language specific
Need to be very careful about run time
errors
Need to ensure semantic consistency
Slide 8
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Inheritance
Single inheritance -- one parent
class
Multiple inheritance -- multiple
parent classes
Redefinition and inheritance conflict
Most inheritance conflicts are due to
poor classification
Slide 9
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Rumbaugh’s Rules
Query operations should not be redefined
Methods that redefine inherited ones should only restrict
the semantics of the inherited ones
The underlying semantics of the inherited method should
never be changed
The signature (argument list) of the inherited method should
never be changed
Slide 10
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Additional Inheritance
Conflicts
Two inherited attributes or methods
have same name and semantics
Two inherited attributes or methods
have different name, but same
semantics
Two inherited attributes or methods
have same name and different
semantics
Slide 11
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Your Turn
A major university graduates about
10,000 students a year and the
development office wants to build a
web-based system to solicit and
track donations.
In such a system, name 3 examples of
classes that might have one subclass;
name 1 example of a subclass that
might have 2 superclasses
Slide 12
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
DESIGN CRITERIA
Slide 13
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Coupling
Interdependency among
modules
Interaction coupling through
message passing
Slide 14
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Law of Demeter
Messages should be sent only by an object
to itself
to an object contained in an attribute of itself or a superclass
to an object that is passed as a parameter to the method
to an object that is created by the method
to an object that is stored in a global variable
Slide 15
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Types of Interactive Coupling
Level
Type
Good
No Direct Coupling
Data
Stamp
Control
Common or Global
Content or Pathological
Bad
Slide 16
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Cohesion
“Single-mindedness of a module”
Method cohesion
Class cohesion
Generalization/specialization
cohesion
Slide 17
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Types of Method Cohesion
Level
Type
Good
Functional
Sequential
Communicational
Procedural
Temporal or Classical
Logical
Coincidental
Bad
Slide 18
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Types of Class Cohesion
Level
Type
Good
Ideal
Mixed-role
Mixed-domain
Worse
Slide 19
Mixed-instance
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Connascence
Creating the need to change
another module as a result of
changing one
Minimize overall connascence
Minimize across encapsulation
boundaries
Maximize within encapsulation boundary
Slide 20
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Types of Connascence
Type
Name
Type or Class
Convention
Algorithm
Position
Slide 21
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
OBJECT DESIGN
ACTIVITIES
Slide 22
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Additional Specification
First review the current set of
models
Sufficient but only necessary
classes to solve problem
No missing attributes or methods
No extraneous attributes or
methods
Examine visibility
Slide 23
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Signatures for each
method
Name of the method
Parameters or arguments to
pass
Type of value the method will
return to the calling method
Slide 24
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Define constraints
Pre-conditions
Post conditions
Invariants
How to handle violations
(exceptions in C++ and Java)?
Slide 25
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Identify Opportunities for
Reuse
Patterns
Framework
Class libraries
Components
Slide 26
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Restructure the Design
Factoring
Map design to current language
Normalization
Assure all inheritance
relationships support only
generalization/specialization
semantics
Slide 27
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Optimizing the Design
Review access paths
Review attributes of each class
Review direct and indirect fan-out
Consider execution order of
statements in often-used methods
Avoid recomputation by creating
derived attributes and triggers
Slide 28
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Constraints and Contracts
A set of constraints and
guarantees
Written in natural language,
structured English, pseudocode,
or formal language
Slide 29
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Invariants on a Class
Diagram
Slide 30
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Simple Contract Format
Method Name:
Class Name:
ID:
Clients (Consumers):
Associated Use Cases:
Description of Responsibilities:
Arguments Received:
Type of Value Returned:
Pre-Conditions:
Post-Conditions:
Slide 31
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
METHOD SPECIFICATION
Slide 32
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Syntax
No formal syntax specification
General information
Events
Message Passing
Algorithm Specification
Slide 33
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Structured English
Slide 34
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Pseudocode Example
(Get CD-info
Accept
Accept
Accept
Accept
Return
Slide 35
module)
(CD_title) {Required}
(CD_artist) {Required}
(CD_category) {Required}
(CD_length)
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Summary
Translating the basic elements of OO analysis
into design requires attention to prevent
difficulties and conflicts in execution.
Coupling, cohesion, and connascence are
proposed for criteria for evaluating design.
The designer will look for opportunities to
optimize the design, will create constraints and
contracts, and will specify methods.
Slide 40
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.
Expanding the Domain
The C and C++ users group is a
source of unusually rich
thoughts regarding OO
development. Check them out
at:
http://www.accu.org/
http://www.accu-usa.org/
Slide 41
PowerPoint Presentation for Dennis, Wixom & Tegarden
Systems Analysis and Design
Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.