information systems development

23
October 2004 J. B. Wordsworth J4ISDDES 1 Information Systems Development Design

Upload: lucita

Post on 30-Jan-2016

29 views

Category:

Documents


0 download

DESCRIPTION

Information Systems Development. Design. Prerequisites. Understand the use of Java as an object-oriented programming language. Write test plans for Java classes. Read UML sequence diagrams. Objectives. Describe the structure of a design document for the API process. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 1

Information Systems Development

Design

Page 2: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 2

Prerequisites

• Understand the use of Java as an object-oriented programming language.

• Write test plans for Java classes.

• Read UML sequence diagrams.

Page 3: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 3

Objectives• Describe the structure of a design document for

the API process.• Understand the use of invariants to constrain Java

class definitions.• Describe the parts of the definition of a method.• Understand how the proposed implementation

represents the elements of the specification.• Describe how to verify that a method implements

an operation of the functional interface specification.

Page 4: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 4

Design document• Specification of the classes

– Specify the names, attributes, and methods of the classes.

– State which class contains the back end interface.

• Specification of the abstraction function– how the class definitions implement the back end

specification.

• Sequence diagrams for the back end functions• Class responsibilities and collaborations

Page 5: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 5

Class definition

• Name

• Attributes

• Invariants

• Constructors

• Methods:– Syntax of invocation– Effect in terms of change of attribute values

Page 6: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 6

Class usage hierarchy

Store

Line

Item

Bill

Page 7: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 7

Line class• Attributes

– String description– int stock– int price

• Methods– void changeStock (int change)– String getDescr ()– int getPrice ()– int getStock ()– void setPrice ( int newprice )

Page 8: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 8

Item class• Attributes

– String line– Item next

• Methods– String getLine ()– void chainItem (Item )– Item unChain ()– Item getNext ()– boolean isEnd ()

Page 9: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 9

Bill class• Attributes

– Item first– Item last– boolean empty

• Methods– void enQueue (Item ite)– Item deQueue ()– boolean isEmpty ()– void remItem (String lnu)

Page 10: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 10

Store class attributes• Hashtable checkouts

– String to null String

• Hashtable bills– String to Bill

• Hashtable lines– String to Line

Page 11: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 11

Store class invariants• (C1) The keys of checkouts are String objects.• (C2) Each key of bills is a key of checkouts.• (C3) The values of bills are Bill objects.• (C4) The keys of lines are String objects.• (C5) The values of lines are Line objects.• (C6) For each Bill object in the values of bills,

if its empty attribute is false, then the line attribute of first, and of any Item object reachable from first by following the next chain, is a key of lines.

Page 12: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 12

Store class constructor

public Store() {

checkouts = new Hashtable ( ) ;

bills = new Hashtable ( ) ;

lines = new Hashtable ( ) ;

}

• Validation opportunity here, but it is an easy one.

Page 13: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 13

Store class methods

• Private methods that provide utility functions– Evaluate predicates to decide which action to take.

– Add things to or remove things from the Hashtables.

• Public methods that provide the back end interface– See also the sequence diagrams for these functions.

Page 14: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 14

A private methodaddCheck

Syntax

void addCheck ( int cnu )

Precondition

cnu is not a key of checkouts.

Postcondition

Adds cnu as a key of checkouts with a null String value.

Page 15: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 15

A public method (1)

addCheckout

Syntax

int addCheckout ( String cnu )

Precondition

None.

Page 16: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 16

A public method (2)

Situation Change of state Outputs

cnu is a key of checkouts.

None. Return 1.

cnu is not a key of checkouts.

Add a null String to checkouts with key cnu.

Return 0.

Postcondition

Page 17: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 17

How the sets are represented• (R1) CheckoutNumber is a non-empty set of

character arrays, represented by String, but is not otherwise defined.

• (R2) LineNumber is a non-empty set of character arrays, represented by String or StringBuffer, but is not otherwise defined.

• (R3) Integer is a non-empty set of integers, represented by int or Integer, but is not otherwise defined.

• (R4) Description is a non-empty set of character arrays, represented by String or by StringBuffer, but is not otherwise defined.

Page 18: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 18

How the subsets and functions are represented (1)

• (R5) checkout_set is the set of keys of checkouts.• (R6) line_set is the set of keys of lines.• (R7) description_function is the function derived

from lines by relating each key to the description attribute of the corresponding Line object.

• (R8) price_function is the function derived from lines by relating each key to the price attribute of the corresponding Line object.

Page 19: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 19

How the subsets and functions are represented (2)

• (R9) stock_function is the function derived from lines by relating each key to the stock attribute of the corresponding Line object.

• (R10) bill_line_function is the function derived from bills by relating each key to the sequence derived as follows: – If the empty attribute of the Bill object is true, the

empty sequence. – Otherwise, the sequence of line attributes from the

sequence of Item objects that begins with first, follows the next attribute, and ends with last.

Page 20: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 20

Verifying a method

• Check that the inputs are the same.• Check that the map of the concrete precondition

satisfies the abstract precondition.• For each concrete partition of the change of state:

– Identify the corresponding abstract partition.

– Check that the concrete change of state corresponds to the abstract change of state.

– Check that the outputs are the same.

Page 21: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 21

addCheckout (cnu)

: Store

isCheck(cnu)

addCheck(cnu)

FALSE

Sequence diagram of a method

Page 22: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 22

TRUE

FALSE

startBill (cnu)

isCheck (cnu)

addBill(cnu, b1)

: Store

isBusy (cnu)

Bill ( )b1 : Bill

A method that creates an object

Page 23: Information Systems Development

October 2004 J. B. Wordsworth J4ISDDES 23

changeLineStock (lnu, lst) isLine (lnu)

changeStock (lst)

TRUE

: Store

getLine ( lnu)

n1

n1 : Line

A method with collaboration