Presentation is loading. Please wait.

Presentation is loading. Please wait.

November 2005J. B. Wordsworth: J5DAMSDI1 Design and Method Specification, Design, Implementation.

Similar presentations


Presentation on theme: "November 2005J. B. Wordsworth: J5DAMSDI1 Design and Method Specification, Design, Implementation."— Presentation transcript:

1 November 2005J. B. Wordsworth: J5DAMSDI1 Design and Method Specification, Design, Implementation

2 November 2005J. B. Wordsworth: J5DAMSDI2 Objectives Understand the process to be followed for design, implementation, and testing. Describe the inputs to and outputs from the design activity. Describe the role of the abstraction function. Write class definitions in an approved style. Plan for the implementation and testing of Java classes.

3 November 2005J. B. Wordsworth: J5DAMSDI3 Analysis Specification Design Implementation Test Planning Testing Begin End

4 November 2005J. B. Wordsworth: J5DAMSDI4 The design activity Read the specification and make sure that you understand it. Propose a design: –Plan possible designs – think forwards about their effects. –Select a design. –Invent the right diagrams and documents to record the design. –Record the chosen design in the design documents. –Verify that the design matches the specification.

5 November 2005J. B. Wordsworth: J5DAMSDI5 Inputs to the design activity Specification information in the FID0 functions: –Arguments (inputs) –Results (outputs) –State components changed and referred to –Constraints to be enforced –precondition and postcondition for each function Specification information in the FID0 state: –State components to be represented –Invariants to be respected –Initialisation of the state Language knowledge

6 November 2005J. B. Wordsworth: J5DAMSDI6 Outputs from the design activity Detailed specifications of the design classes: –Name –Attributes: names, types, constraints, initial values –Constructors: inputs, values of attributes of aresulting object –Methods: names, arguments, results, description of intended effects in various cases (Correctness argument for the design decisions) Sequence diagrams for each back end function and its variants (next lecture)

7 November 2005J. B. Wordsworth: J5DAMSDI7 A conceptual (class) diagram Newsagency Paper Customer 0..* Order 1 1 satisfies requires 1 1 1 0..* addr: String name: String num: Int

8 November 2005J. B. Wordsworth: J5DAMSDI8 Some constraints Customers have unique names. Papers have unique names. The num in Paper is the number of Order objects linked to it.

9 November 2005J. B. Wordsworth: J5DAMSDI9 A specification fragment CustomerName, Address, PaperName : Base_Type Customer : tuple_of ( address : Address ) customer_function : mapping_from CustomerName to Customer paper_function : mapping_from PaperName to Integer order_relation : relation_between CustomerName and PaperName customer_list : sequence_of CustomerName paper_list : sequence_of PaperName

10 November 2005J. B. Wordsworth: J5DAMSDI10 Specification invariants (B1) dom ( order_relation )  dom ( customer_function ) (B2) ran ( order_relation )  dom ( paper_function ) (B3) ran ( customer_list )  dom ( customer_function ) (B4) ran ( paper_list )  dom ( paper_function ) (B5)  pn  dom ( paper_function ) ( paper_function ( pn ) = | { ord | ord  order_relation  ord.2 = pn } | )

11 November 2005J. B. Wordsworth: J5DAMSDI11 Some design decisions Attributes of Newsagency: –customers: a Hashtable to relate customer name (String) to a Customer object reference –papers: a Hashtable to relate paper name (String) to a Paper object reference Attributes of Customer: –addr (a String) Attributes of Paper: –num (an integer) Attributes of Order: –paper (a Paper object reference), cust (a Customer object reference)

12 November 2005J. B. Wordsworth: J5DAMSDI12 Sample function: specification addCustomer ( cna, cad ) returns status precondition cna  CustomerName  cad  Address postcondition case: cna  dom ( customer_function ) do status := 1 case: cna  dom ( customer_function ) do customer_function ( cna ) := ( addr := cad ) & status := 0 Preserves (B1) and (B3)

13 November 2005J. B. Wordsworth: J5DAMSDI13 Defining the behaviour of a Java method: addCustomer InputSituationChange of stateOutput cn ca cn is a key of customers. None.Return 1. cn is not a key of customers. Let cc be a new Customer object with addr = ca. Add the pair ( cn, cc ) to customers. Return 0. int addCustomer ( String cn, String ca ) ; Precondition None. Postcondition

14 November 2005J. B. Wordsworth: J5DAMSDI14 Justifying the data design decisions The abstraction function explains how each specification structure can be retrieved from the Java data structures. Watch your language! Example: customer_function (S) is the set of pairs whose first members are the keys of customers (J), and whose second members are the tuples containing the addr (J) attributes of the corresponding Customer (J) objects.

15 November 2005J. B. Wordsworth: J5DAMSDI15 Verification of a method Check that the name of the operation, the inputs, and the outputs agree. For each situation in the design: –Decide which partition of the specification corresponds. –Check that the design change of state agrees with the specification change of state. –Check that the design output is equal to the specification output.

16 November 2005J. B. Wordsworth: J5DAMSDI16 Implementation Write the Java classes from the class definitions provided by the design. Test each class as you write it, starting at the bottom of the class hierarchy.

17 November 2005J. B. Wordsworth: J5DAMSDI17 Summary The design process accepts specifications and produces definitions of classes for programming. Class definitions can be compared with specifications (verification) and with one another (consistency). The Java classes are written from the class definitions, and tested.


Download ppt "November 2005J. B. Wordsworth: J5DAMSDI1 Design and Method Specification, Design, Implementation."

Similar presentations


Ads by Google