Professional Documents
Culture Documents
SDaA Merged
SDaA Merged
Robustness
Requirements
Analysis
Design
Framework Architecture Detailed Design
Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
Correctness Interfaces Modularization Robustness Design Details 2/24
Correctness
Correctness
Goal: That each artifact satisfies designated
requirements, and that together they satisfy all
of the application’s requirements.
Correctness Interfaces Modularization Robustness Design Details 3/24
Approaches to correctness
• How can we know that a design is correct or even sufficient?
• Approaches to correctness
• Informal approaches
• Formal approaches
• Formal approaches
• Formal methods for establishing correctness involve applying
mathematical logic to analyzing the way in which the variables change
• Formal methods are usually applied when the design enters the
detailed design
Correctness Interfaces Modularization Robustness Design Details 4/24
Informal approaches to
correctness
• Correctness by Informal Methods
Simplify and modularize designs until they are
convincing.
• Informal Approaches
• Informal approaches are based on the common sense idea
that before we can proclaimed a design to be correct, we
have to understand it completely.
• Informal approaches require that design must be
• Readable (to enhance understanding)
• Modular (to deal with complexity)
Correctness Interfaces Modularization Robustness Design Details 5/24
Interfaces to modules
• Modularity
• Modularization is key to assess the correctness of a
design
• A module can be either a class or a package of classes
• An interface is a set of functions forms (or prototypes).
Correctness Interfaces Modularization Robustness Design Details 10/24
Interfaces to modules
• Interfaces to classes
• When a class supports many methods, it is often
beneficial to group them into several interfaces
Shipment
• Grouping allows reuse setVehicle()
perishable()
getWidth()
printRoute()
describeType()
getLength()
getDuration()
setType()
Correctness Interfaces Modularization Robustness Design Details 11/24
Introducing Interfaces
Dimensions TransportationMeans GoodsType
getWidth() getDuration() describeType()
getLength() setVehicle() setType()
getWeight() printRoute() perishable()
Original form
Shipment Shipment
setVehicle()
perishable()
getWidth() Forms using
printRoute() interfaces Dimensions
describeType()
getLength() Shipment TransportationMeans
getDuration()
setType() GoodsType
Correctness Interfaces Modularization Robustness Design Details 12/24
Interfaces to modules
• Interfaces to Packages
• Interface to package is different idea than an interface to
a class
Package Interfaces
purchases
Pricing
Furniture
«singleton»
Clothing PurchasesIF Selection
Appliance ClothingTryout
Correctness Interfaces Modularization Robustness Design Details 14/24
ConversationManager
ServerComm Participant-
services chatClient
billing Display
Message-
Accounting Bill reception ClientComm
Financial
Correctness Interfaces Modularization Robustness Design Details 15/24
Modularization
• To modularize an object-oriented
application
• Create packages at the higher level
• Create classes at the lower level
Modularization
• Choosing packages
• Essential part of choosing an application’s architecture
• Decompose application into a set of packages (typically
3 to 10)
Correctness Interfaces Modularization Robustness Design Details 18/24
Robustness
Sources of Errors
• Robustness --- ability to handle anomalous
situations even in the presence of errors
• Sources of error:
• Faulty input
• User input
• Input, not from users
• Data communication
• Function calls made by other applications
• Developer errors
• Faulty design
• Faulty implementation
Correctness Interfaces Modularization Robustness Design Details 20/24
Constraints on Parameters
Example:
int computeArea( int aLength, int aBreadth ) { … }
❑Capture parameter constraints in classes if feasible
int computeArea( RectangleDimension a RectangleDimension )
❑Specify all parameter constraints in method comments
aLength > 0 and
aBreadth > 0 and
aLength >= aBreadth
❑Callers obey explicit requirements on parameters
• Problem is method programmers have no control over callers
❑Check constraints first within the method code
if( aLength <= 0 ) ……
• Throw exception if this is a predictable occurrence
• Otherwise abort if possible
• Otherwise return default if it makes sense in context
• And generate warning or log to a file
Correctness Interfaces Modularization Robustness Design Details 21/24
Design Details
• How much is enough?
• Most detailed design provide
• Class, sequence, state, and activity models
• Provide activity diagram or pseudocode for
complex methods only
• Code before design?
• Depends of the nature of the task and the experience of
the programmer.
• Design details through a graph
Correctness Interfaces Modularization Robustness Design Details 23/24
Diminishing ability
of designer to
envisage
Experienced consequences of
designer design decision.
Very simple 0% Very complex
Type of application
Correctness Interfaces Modularization Robustness Design Details 24/24
Aspects of Flexibility
Alternative Situations
• Accommodate adding new kinds of functionality
• Adding functionality to an application: alternative
situations: Within the scope of …
1. Within the scope of a list of related functions
Example: add print to an air travel itinerary functions
2. Within the scope of an existing base class
Example: add “print road- and ship- to air itinerary ”
3. Within the scope of: neither
Example: add “print itineraries for combinations of air, road
and ship transportation”
Flexibility Reusability Efficiency Trade-off between Principles 6/24
Trip
SomeApplicationClass
printItinerary()
Student Course
Customer
computeBill()
(1) Leveraging inheritance
RegularCustomer
computeBill()
Customer (2) Leveraging
computeBill() aggregation
Customer Bill
computeBill() compute()
Customer Orders
(3) Leveraging
computeBill( Orders ) value()
dependency
Flexibility Reusability Efficiency Trade-off between Principles 15/24
Efficiency
• Applications must execute required
functionality within required time constraints
Space-Time Trade-offs
Time to process one item
Typical target
Space
Flexibility Reusability Efficiency Trade-off between Principles 17/24
Speed efficiency
• Real-time applications are the
most demanding in terms of
speed
• Function calls
– -- if the function called results in the above
• Object creation
Flexibility Reusability Efficiency Trade-off between Principles 20/24
Trade-off Between
Number of Remote Calls and
Volume retrieved Volume Retrieved at Each Call
at each access
Typical target
Calculator CalcDisplay
solicitNumAccounts() display()
CommandLineCalculator
main()
executeAdditions() CalcOperation
solicitNumberAccounts() execute()
getAnInputFromUser()
interactWithUser()
❑Reusability
– in other applications
❑Efficiency
– in time
– in space
Object Orientation
Objectives
Software
Design
Entities
Object Orientation
Real world concepts Skljkvjkvjfkavjafkk
saovjsdvjfvkfjvkfjk
Skljkvjkvjfkavjafkk
saovjsdvjfvkfjvkfjk
Skljkvjkvjfkavjafkk
saovjsdvjfvkfjvkfjk
Skljkvjkvjfkavjafkk
saovjsdvjfvkfjvkfjk
Direct
correspondence
Benefits of OO
class PermissionToPay
Mental
PermissionToPay { . . . .
concept }
Auto aliceBrownBMW:Auto
public int vehicleID … 33024
protected int mileage …
private myPrivateVariable … … mileage
static int numAutosMade … Static variable: 12390924850984
One version only numAutosMade
Subclasses
have these
members
myToyota:Toyota jaynesCar:Auto
too 2105 83402
mileage mileage
… …
Toyota
…
SWE 316: Software Design and Architecture
Object Orientation Classes and Objects Example Polymorphism Interfaces Things to be considered 9/24
Attribute Types
Naming:
fixed for each object Auto
distinguishes individuals
vehicleID
Descriptive:
varies through life of object mileage
Referential:
owner
ties instance of one class to instance(s) of another
== aggregation
❑ Polymorphism (Sec
❑ Instantiation (Sec 2.3.2)
2.2.2) capturing use of single
creating instances of action word to represent
encapsulated concepts different things,
depending on context
SWE 316: Software Design and Architecture
Object Orientation Classes and Objects Example Polymorphism Interfaces Things to be considered 13/24
3. Future enhancements
Disadvantages of Branching
Code for each case not cohesive
(“cohesive”: forms a comprehensible unity)
All types of customers coded together in single class
Expensive to …
… add new functionality
bloat switch or if - then code
… remove functionality
hunt for all parts that must be removed
… change functionality
hunt for all parts that must be changed
Return type
Example: double, reference
type, void
Polymorphism
the use of several versions of a
method, one in each derived class.
This enables
objectOfBaseClass.theMethod() to be
interpreted variously at runtime,
depending on what derived class
objectOfBaseClass belongs to.
class Draw
{ …
int setColor( String ) { … }
Pen getStandardPen() { … }
int getLogoStyle() { … }
void setColor( int ) { … }
void drawLogo( int, int ) { … }
void speedUpPen( int ) { … }
…
}
Interfaces
Issues to be Addressed
How do we visualize a set of classes?
How can classes relate to each other?
How should classes relate to each other?
How can we describe functionality occurring among
several classes?
How do we describe the manner in which objects
respond to events occurring on them?
Are there patterns of class usage that recur?
So we can existing reuse design parts
SWE 316: Software Design and Architecture
Object Orientation Classes and Objects Example Polymorphism Interfaces Things to be considered 24/24