230 likes | 392 Views
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.
E N D
Information Systems Development Design J. B. Wordsworth J4ISDDES
Prerequisites • Understand the use of Java as an object-oriented programming language. • Write test plans for Java classes. • Read UML sequence diagrams. J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
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 J. B. Wordsworth J4ISDDES
Class definition • Name • Attributes • Invariants • Constructors • Methods: • Syntax of invocation • Effect in terms of change of attribute values J. B. Wordsworth J4ISDDES
Class usage hierarchy Store Bill Line Item J. B. Wordsworth J4ISDDES
Line class • Attributes • String description • int stock • int price • Methods • void changeStock (int change) • String getDescr () • int getPrice () • int getStock () • void setPrice ( int newprice ) J. B. Wordsworth J4ISDDES
Item class • Attributes • String line • Item next • Methods • String getLine () • void chainItem (Item ) • Item unChain () • Item getNext () • boolean isEnd () J. B. Wordsworth J4ISDDES
Bill class • Attributes • Item first • Item last • boolean empty • Methods • void enQueue (Item ite) • Item deQueue () • boolean isEmpty () • void remItem (String lnu) J. B. Wordsworth J4ISDDES
Store class attributes • Hashtable checkouts • String to null String • Hashtable bills • String to Bill • Hashtable lines • String to Line J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
Store class constructor • public Store() { • checkouts = new Hashtable ( ) ; • bills = new Hashtable ( ) ; • lines = new Hashtable ( ) ; • } • Validation opportunity here, but it is an easy one. J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
A private method addCheck 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. J. B. Wordsworth J4ISDDES
A public method (1) addCheckout Syntax int addCheckout ( String cnu ) Precondition None. J. B. Wordsworth J4ISDDES
A public method (2) Postcondition J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
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. J. B. Wordsworth J4ISDDES
addCheckout (cnu) : Store isCheck (cnu) FALSE addCheck (cnu) Sequence diagram of a method J. B. Wordsworth J4ISDDES
A method that creates an object : Store startBill (cnu) isCheck (cnu) TRUE isBusy (cnu) FALSE Bill ( ) b1 : Bill addBill (cnu, b1) J. B. Wordsworth J4ISDDES
: Store n1 : Line changeLineStock (lnu, lst) isLine (lnu) TRUE getLine ( lnu) n1 changeStock (lst) A method with collaboration J. B. Wordsworth J4ISDDES