Object Oriented Analysis and Design System Events & Contracts
Object Oriented Analysis and Design Software Requirements Specification What are the business needs ? (long text) Use Cases What are the domain process ? (text + visual notation) Conceptual Model What are the concepts, terms ? (visual) System Sequence Diagrams What are the system events, operations ? (visual) Collaboration / sequence Diagrams How software objects interact to fulfill task ? (visual) Contracts What do the system operations do ? (text) Design Class Diagrams What is the specification for the software classes ? (visual)
System Sequence Diagrams Corresponds to: Buy Item Use Case Cashier :System enterItem(UPC,quantity) endSale() makePayment(amount) Repeat until no more items
System Sequence Diagrams System Response: 3. Determines item price and adds item info to the running sales transaction Description and price of the current item is presented 5. Calculates and presents sale total Actor Actions: This use case begins when a Customer arrives at a POST checkout system with items to purchase 2. Cashier records the identifier for each item. If there is more than one of the same item, Cashier enters the quantity 4. On completion of item entry, Cashier indicates to POST that item entry is complete 6. Cashier tells Customer the total Cashier :System enterItem(UPC,quantity) endSale() makePayment(amount)
System Sequence Diagrams elements Corresponds to: Buy Item Use Case System BLACK BOX Actor Cross reference to use case Cashier :System enterItem(UPC,quantity) endSale() makePayment(amount) System event Repeat until no more items Text to clarify logic, control, iterations, etc..
System Sequence Diagrams elements
System Sequence Diagrams Identifying system events It is necessary to be clear about the system boundary Actors to be considered are those who trigger the system Costumer is not an actor ! From use case typical course of events, identify system (external) events
System Sequence Diagrams Naming System Events Express at the level of intent rather than in terms of physical input medium Preferably, start the name with a verb endSale() ESCPressed() makePayment(amount) enterAmountTendered(amount) enterPayment(amount) Better Worse
Object Oriented Analysis and Design Software Requirements Specification What are the business needs ? (long text) Use Cases What are the domain process ? (text + visual notation) Conceptual Model What are the concepts, terms ? (visual) System Sequence Diagrams What are the system events, operations ? (visual) Collaboration / sequence Diagrams How software objects interact to fulfill task ? (visual) Contracts What do the system operations do ? (text) Design Class Diagrams What is the specification for the software classes ? (visual)
Contracts Describes what an operation commits to achieve Depends on What will happen rather than how it will be achieved Depends on conceptual model system sequence diagrams identification of system operations
Contracts example: enterItem Name: enterItem(upc:number, quantity:integer) Responsibility: Enter (record) sale of an item and add it to sale. Display item description and price. Type: System Cross References: System Functions: R1.1, R1.3, R1.9. Use Cases: Buy Items Notes: Use fast dbase access Exceptions: If UPC is invalid, indicate an error Pre-Conditions: UPC is known to system
Contracts example: enterItem Post-Conditions: If new sale, a Sale was created (instance creation) If new sale, new Sale was associated with POST (association formed) A SalesLineItem was created (instance created) SalesLineItem was associated with Sale (association formed) SaleLineItem.quantity was set to quantity (attribute modification) SaleLineItem was associated with ProductSpecification based on UPC match (association formed)
Contracts Contract Sections Name: Name of operation, and parameters Responsibilities: An informal description of responsibilities this operation must fulfill Type: Name of type (concept, software class, interface) Cross References: System function reference numbers, use cases, etc. Notes: Design notes, algorithms, etc. Exceptions: Exceptional cases
Contracts Contract Sections Output: Non-UI outputs such as messages or records that are sent outside of system Pre-Conditions: Assumptions about the state of system before execution of operation Post-Conditions: The state of system after completion of operation
Contracts How to make Contracts Identify system operations from system sequence diagrams For each system operation, construct a contract Start by writing responsibilities section Then complete post conditions section Then move to pre-conditions section
Contracts How to make Contracts Writing post conditions It should describe the state changes that occur to objects in the conceptual model (rather than actions) Possible state changes: Instance creation or deletion Attribute modification Association formed or broken
Contracts How to make Contracts Writing post conditions Use past passive tense form (was..) Establish memory between existing objects: The most common mistake: not forming associations Association to several objects is very likely Think of the system and its object like a stage in a theatre Craig Larman
Contracts More on Contracts Generating complete and accurate set of post-conditions is not likely and not necessary Following pre-conditions worth capturing: Things that are important to test in software Things that affect the success of operation Use notes section to capture known design statements Use exceptions section to discuss reaction to exceptional situations
From Use Cases to Contracts Buy Item … Typical Course of Events: Use Case Contracts Operation: enterItem … Post-conditions: 1. … endSale Cashier System enterItem endSale makePayment System Sequence Diagram System enterItem() endSale() makePayment() Operations
More example (from larman’s book) Contracts More example (from larman’s book)
More example login use case contract Contracts More example login use case contract
Use Case Description
Object Oriented Analysis and Design Software Requirements Specification What are the business needs ? (long text) Collaboration / sequence Diagrams How software objects interact to fulfill task ? (visual) Use Cases What are the domain process ? (text + visual notation) Conceptual Model What are the concepts, terms ? (visual) System Sequence Diagrams What are the system events, operations ? (visual) Contracts What do the system operations do ? (text) Design Class Diagrams What is the specification for the software classes ? (visual)