Download presentation
Presentation is loading. Please wait.
1
Object Specification Moving towards a more precise specification of software
2
Sequence (object interaction) diagrams Provide detail on the interaction between objects and the division of responsibility between objects- which classes hold which operations. When this is clear we can then look at providing more detail on significant (or more complex) operations.
5
Operation specification describes the detailed behaviour of the system. adds detail and precision so that user can check if requirements are met. Provides more detail for software design and helps in coding.
6
Example : Black box specification ‘Contract’ describes the external interface of an object and its signature. We know what goes in We know what comes out We know what the message does We don’t know how it does it. Balance Getaccountbalance
7
Contracts Intent or purpose of the operation Operation signature : parameters and return type Description of the logic Other operations called Events transmitted to other objects Response to exceptions
8
Delay flight alters the flight duration by the number of minutes specified. Get arrival time returns the time of arrival. Why do we need to be specific here? Examples from IBM Rational class diagrams
9
Non-algorithmic (declarative) Approaches Describe the logic of the operation as a black box. Show Operation Signatures or message protocols useful where a structured decision has to be made- the description is used to determine the conditions that determine the outcome. E.g. decision tables, pre and post conditions, OCL (Object Constraint Language )
10
Decision Tables A decision table is a matrix that shows the conditions under which a decision is made, the actions which can result and how the two are related. Steps in Drawing a Decision Table 1.List all conditions 2.List all possible actions 3.Fill in true/false values 4.Assign actions 5.Ensure all possibilities have been covered. These are useful for situations where there are many outcomes depending on various combinations of input conditions.
11
Decision Table example – register student on water safety RULE 1RULE 2RULE 3 Conditions Has student the prerequisite qualification? YNYN Is student old enough?YYNN Action Register Studentx Register on prerequisite (if qualified and old enough) xx Repeat or put on endurance training x
12
Decision Table example – can player get out of jail? RULE 1RULE 2RULE 3RULE 4 Conditions Has player get out of jail free card? YNNN Have they had 3 turns?NYNN Have they paid £50?NNYN Action Let outxxx Keep in Jailx
13
Decision Table RULE 1RULE 2RULE 3RULE 4 Conditions Actions
14
Precondition : what is true/must be true before the method or operation is executed Postcondition: what is true/must be true after the method or operation is executed. Where have we seen pre and post conditions before?
15
Example : enrol(student, module) Precondition Postcondition
16
Object Constraint Language (OCL) This is used if a much more formal and precise specification is needed. This is a language with a strict syntax used to specify, for example, pre and post conditions.
17
in some cases there may be a need to describe an object’s logic or internal behaviour- though this is essentially a design activity
18
Algorithmic Approaches Algorithm- describes the internal logic of a process or decision by breaking it down into small steps. Uses sequence, selection, iteration and recursion Example Approaches Structured English/pseudocode Activity diagrams, flowcharts
19
Structured English Operation: withdraw_cash (amount) If amount <= bank balance Subtract amount from bank balance Otherwise Display bank balance Display error message.
20
Pseudocode If amount <= bank balance { balance = balance – amount; success =true; else { Display bank balance Display error message Success = false } return(success)
21
Activity diagrams e.g. Make Booking systemcustomer
22
Example: An operation in monopoly to check whether a player can buy a hotel If the player has the full colour set AND none of them are mortgaged AND the player has four houses on the property AND the player has enough money for one house They can exchange the four houses for a hotel. If they have the full colour set AND none of them are mortgaged AND they have less than four houses, AND enough money for one house, they can buy a house..... If they have the full colour set,..... Use a decision table to lay out the rules more efficiently
23
An operation is required to calculate a fine for an overdue DVD loaned by a video shop. The number of days overdue is calculated by subtracting current date from the due date. If the DVD is a category A ( current top 10), then the fine is €1 per night for the first 15 nights, and thereafter the full cost of the DVD will be charged. If the DVD is a category B, the fine is €0.50 per night for the first 20 nights and thereafter the full cost of the DVD will be charged. For DVDs of category C (old DVDs) the charge is €0.30 per night for the first 20 nights and after that there is no further charge.
24
class loan { dvd id : int category : char loan date : date due date : date float calculate_fine(todaysdate:date) }
25
Operation calculate fine 1. Draw a decision table 2. Write some pseudocode or structured english 3. Draw an activity diagram
26
Conditions Category AYYNNNN Category BNNYYNN Category CNNNNYY >15 nights overdueNYNNNY >20 nights overdueN-NYNY Actions Charge cost of DVD** Charge 0.30 *20* Charge €1 per night* Charge €0.50 per night* Charge €0.30 per night*
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.