Transcript of Chapter 4 Design Principles I Correctness and Robustness.
- Slide 1
- Chapter 4 Design Principles I Correctness and Robustness
- Slide 2
- Process Phase Affected by This Chapter Requirements Analysis
Design Implementation ArchitectureFrameworkDetailed Design Key:=
less affected Adapted from Software Design: From Programming to
Architecture by Eric J. Braude (Wiley 2003), with permission.
- Slide 3
- Key Concept: Correctness Goal: That each artifact satisfies
designated requirements, and that together they satisfy all of the
applications requirements. Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 4
- Sufficient Designs: Terminology and Rationale A design
sufficient to implement the requirements. a correct design
Sometimes called the design must be entirely understandable It
follows that the design very modular A common way to achieve this
is to make Minimum goal: Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 5
- Key Concept: Correctness by Informal Methods Simplify and
modularize designs until they convince. Adapted from Software
Design: From Programming to Architecture by Eric J. Braude (Wiley
2003), with permission.
- Slide 6
- -- with variables mileage, VehicleID, value, originalPrice, and
type : 1)mileage > 0 2)mileage < 1000000 3)vehicleID has at
least 8 characters 4)value >= -300 ($300 is the disposal cost of
a worthless automobile) 5)originalPrice >= 0 6)( type == REGULAR
&& value = originalPrice ) Invariants for Class Automobile
Adapted from Software Design: From Programming to Architecture by
Eric J. Braude (Wiley 2003), with permission.
- Slide 7
- Introducing Interfaces 1 of 2 Shipment setVehicle()
perishable() getWidth() printRoute() describeType() getLength()
getDuration() setType() Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 8
- Introducing Interfaces 2 of 2 Shipment setVehicle()
perishable() getWidth() printRoute() describeType() getLength()
getDuration() setType() Shipment Dimensions getWidth() getLength()
getWeight() TransportationMeans getDuration() setVehicle()
printRoute() GoodsType describeType() setType() perishable()
Shipment Dimensions TransportationMeans GoodsType Original form
Forms using interfaces Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 9
- Package Interfaces Pricing purchases Furniture Clothing
Appliance Selection ClothingTryout singleton PurchasesIF Adapted
from Software Design: From Programming to Architecture by Eric J.
Braude (Wiley 2003), with permission.
- Slide 10
- Participant- services Conversation- services Example of Package
Interfaces Conversation chatServer chatClient Display
ConversationManager ClientComm ServerComm billing AccountingBill
Financial Message- reception Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 11
- Key Concept: Interfaces -- collections of function prototypes:
Make designs more understandable. Adapted from Software Design:
From Programming to Architecture by Eric J. Braude (Wiley 2003),
with permission.
- Slide 12
- Domain vs. Non-Domain Classes o Domain classes : Particular to
the application o Examples: BankCustomer, BankTransaction, Teller o
Typically not GUI classes o Sufficient to classify all requirements
(see chapter xx) o Non-Domain classes : Generic o Examples:
abstract classes, utility classes o Arise from design and
implementation considerations Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 13
- Alternative Modularizations mechanics position ground control
onBoardNavigation control trajectory weather Application tracking
trajectory of rocket carrying orbit-bound satellite into position
Alternative 1 Alternative 2 Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 14
- 1.Protection from faulty Input o User input o Input, not from
user Data communication Function calls made by other applications
2. Protection from developer error o Faulty design o Faulty
implementation Improving Robustness: Sources of Errors Adapted from
Software Design: From Programming to Architecture by Eric J. Braude
(Wiley 2003), with permission.
- Slide 15
- 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 o Problem is method programmers have no
control over callers Check constraints first within the method code
if( aLength
- Wrapping Parameters Replace int computeArea( int aLength, int
aBreadth ) {..} with int computeArea( Rectangle aRectangle ) {..}
-- where class Rectangle { Rectangle( int aLength, int aBreadth ) {
if( aLength > 0 ) this.length = aLength; else .. } } Adapted
from Software Design: From Programming to Architecture by Eric J.
Braude (Wiley 2003), with permission.
- Slide 18
- Key Concept: Robustness -- is promoted by enforcing intentions.
Adapted from Software Design: From Programming to Architecture by
Eric J. Braude (Wiley 2003), with permission.
- Slide 19
- How Much Design Detail Before Initial Coding? 0% Recommen- ded
% of design detail before starting to code Very simpleVery complex
Inexperienced designer Experienced designer 100% Type of
application Diminishing ability of designer to envisage
consequences of design decision. Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.
- Slide 20
- Summary of This Chapter Correctness of a Design or Code o
Supports the requirements o In general, many correct designs exist
Robustness of a Design or Code o Absorbs errors o -- of the user o
-- of developers Adapted from Software Design: From Programming to
Architecture by Eric J. Braude (Wiley 2003), with permission.
- Slide 21
- Video Store Application: Sufficient Classes? Video Customer
BarCodeReader CheckOutDisplay RegisterNewVideoDisplay
CheckOutDurationDisplay Adapted from Software Design: From
Programming to Architecture by Eric J. Braude (Wiley 2003), with
permission.