View
218
Download
0
Category
Tags:
Preview:
Citation preview
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
System/Program specifications
• What should the system/program do ?
• Formally:– Set of all possible inputs {I}– Set of all possible outputs {O}– Function mapping all elements of {I} into
elements of {O}
• Possible for simple and small programs
• Unfeasible for large scale systems
The effort of Specifying
Interactionswith otherprograms
Number of users
Only the author
Many,
None Many
1
9
3
3
System/Program specifications
• Specifications for large scale systems ?
1 Make reasonable set of specifications
2 REPEAT
2.1 Build prototype
2.2 Evaluate prototype
2.3 Update specifications
UNTIL satisfaction of (potential) users
3 Write down final specifications
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
The Cost of Software
for large systems
Design (18%)
Coding (7%)
Debugging(25%)
Maintenance(50%)
During design and coding efforts should be madeto reduce the cost of debugging and maintenance
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Design Methods
• Top-down design: From global to detail– Decompose the problem in simpler subproblems– Further decompose subproblems– UNTIL all subproblems have trivial solutions
• Bottom-up design: From detail to global– Solve some small problems that might be useful
for solving the big problem– Use the partial solutions for assembling a global
solution
Example : Repairing a flat tire
• Specifications : – Given : A car with a flat tire– Wanted : Instructions for fixing it
• Strategy choice :– Wait with a smile until somebody fixes it …– Call a repair service> Try to repair yourself
Repairing a flat tire
“Data” and Actions
• “Data”– Car, Defective wheel, Spare wheel, Tools.
• Actions– All that need to be done with the Car, the
Defective wheel, the Spare wheel and the Tools in order to solve the problem.
Repairing a flat tire
Top level design of actions
• Inspect the spare wheel
• If available and in good condition,
– Then, repair yourself
– Else, you will need to call help
Repairing a flat tireRefinement of “repair
yourself”
• Fetch the tools
• Fetch the spare wheel
• Exchange defective and spare wheels
• Store defective wheel
• Store tools
Repairing a flat tire
Refinement of “tools”
• Tools :– Jack : device to lift a car– Wrench : device to loose or fasten bolts
Repairing a flat tireRefinement of “Exchange defective and spare
wheels”• REPEAT loose one bolt with wrench UNTIL all bolts loose;• Lift car with Jack;• REPEAT remove one bolt UNTIL all bolts removed;• Remove defective wheel;• Put spare wheel in place;• REPEAT replace one bolt UNTIL all bolts in place;• Lower car with Jack;• REPEAT fasten one bolt with wrench UNTIL all bolts fastened;
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Object oriented Design
• Problem : – If a data item is slightly changed, the entire
program needs to be checked.
• Solution :– Group data with description of all actions
that can be performed upon such data– Access data exclusively through the actions
predefined for these data
• Object = data + actions to access it.
Repairing a flat tire
Object-oriented style
• Instance of the object :• MyJack
• Possible actions :• Fetch
• Inspect
• Store
• Lift a car
• Lower a car
Object Jack =
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Repairing a flat tire
Decision TableSpare Wheel
Tools
Available & OK
No good tools available
OK Not OK
Repairyourself
Get Help
Get Help
Try toborrowtools
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Repairing a flat tireRefinement of “repair
yourself”
Spare WheelOK ?
Get Help Repairyourself
No Yes Get Tools
Get Spare Wheel
Change Wheel
Store Bad Wheel
Store Tools
Repairing a flat tire
Refinement of “Get Tools”
Tools present & OK ?
Tools present & OK ?
Pick up the Tools
Try borrowing Tools
NoYes
Got Tools or Tired ?
Yes
Yes
No
No
Help Needed !!!
Repairing a flat tireAdapted refinement of “Get
Tools”
Tools present & OK ?
Pick up the Tools
Try borrowing Tools
NoYes
Got Tools or Tired ?
Yes
No
Repairing a flat tire
Improved top-level design
Spare Wheel OK ?
No Yes
Tools OK ?
Fetch Tools
Yes
No
Get Help Repairyourself
Selection Statement
No
selector = a ? Tasks to be doneif selector = A
Yes
No
selector = b ? Tasks to be doneif selector = B
Yes
No
selector = c ? Tasks to be doneif selector = C
Yes
Tasks to be doneif no criteria OK
Selection Statement
selectorTasks to be done
if selector = A
selector = a
Tasks to be doneif no criteria OK
selector # aselector # bselector # c
Tasks to be doneif selector = B
Tasks to be doneif selector = C
selector = b selector = c
selector
Iteration Statement
Termination Test
Initialization
Loopbody, part 1
Loopbody, part 2
Continue
Finish
Repairing a flat tire
Spare Wheel ?
Not OK OK
Get
Help
Fetch Tools
Tools ?
Get
Help
Repair
Yourself
Not OK OK
Tools present & OK ?
Yes No
Get
your
own
tools
Try toborrowtools
Until You got tools OR you are tired
Get spare wheel
Change wheel
Store bad wheel
Return tools
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
State Diagrams
Flat tire problemDriving
Flat tire
Need help Goodspare wheel
Repairing
Try borrowtools
Puncture
No goodSpare wheel
Successfulhelp
Nosuccess
Spare wheelOK
Done
Notools Tools
OK
Success
State Diagrams
Electronic lockFirst digitentered
Waiting1st digit
Testing key
Waiting2nd digit
Waiting3rd digit
Second digitentered
Third digitentered
Wrong Key Opening door
Good Key
Spontaneoustransition
Summary• System/Program specifications
• System/Program design– Top-down & Bottom-up design– Object Oriented design
• Tools for system/program documentation– Decision tables– Control-flow & Nassi-Shneiderman diagrams– Data-flow diagrams– State diagrams– Unified Modeling Language
Unified Modeling Language
• Tool for supporting / documenting object oriented designs• Applicable to the
– Organizational level– System level– Program level
• Set of different diagrams, including– Class diagrams (= objects and their static relations)– Interaction diagrams– Activity diagrams (= extended control flow diagrams)– State diagrams– Deployment diagrams
Recommended