Use Case Model Operation Contracts Prepared By: Sumit Sharma and Sravanthi Gillala.

Slides:



Advertisements
Similar presentations
Object Design Examples with GRASP
Advertisements

System Sequence Diagrams
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Jan 23, Ron McFadyen1 SSD for a samplePOS Use Case Figure 13.1 Input Events invoke a system operation of the same name same idea as in object-oriented.
Object-Oriented Analysis and Design
Drawing System Sequence Diagrams
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
NJIT Use Case Model Operation Contracts Prepared By: Sumit Sharma.
6/8/991 Analysis Tuesday 09/14/99 Revised: September 11, 2000 (APM)
ACS-3913Fall 2009 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
NJIT 1 Domain Model Visualizing Concepts Chapter 9 Applying UML and Patterns Craig Larman.
September 2002 R McFadyen1 Domain Model Use Case Model text diagram SSD System operation contracts Design Model Figure 13.3.
NJIT Drawing System Sequence Diagrams Chapter 10 Applying UML and Patterns Craig Larman Presented by Anuradha Dharani.
Object-Oriented Analysis and Design
Sept Ron McFadyen1 Extend Relationship.
חוזים – Contracts 1. Larman – Chapter 10 – SSDs 10.2 What are System Sequence Diagrams? (introduction) Use cases describe how external actors interact.
9/18/011 Software Requirements Analysis and Design (Continued)
TK2023 Object-Oriented Software Engineering CHAPTER 6 SYSTEM SEQUENCE DIAGRAMS.
Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative Development Part III Elaboration Iteration I – Basic1.
INFO 620Lecture #51 Information Systems Analysis and Design Sequence and Collaboration Diagrams INFO 620 Glenn Booker.
CSSE 374: Operations Contracts and Logical Architectures Steve Chenoweth Office: Moench Room F220 Phone: (812)
Chapter 18 Object Design Examples with GRASP. Objectives Design use case realizations –A use-case realization describes how a particular use case is realized.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
Object-Oriented Analysis and Design Feb 4, 2009.
1 Ch 18. Object Design Examples With Grasp Objectives Design use case realizations. Apply GRASP to assign responsibilities to classes. Apply UML to illustrate.
Object Oriented Analysis and Design System Events & Contracts.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Chapter 6 Use Cases. Use Cases: –Text stories Some “actor” using system to achieve a goal –Used to discover and record requirements –Serve as input to.
GRASP: Designing Objects With Responsibilities Chapter 17 Applying UML and Patterns -Craig Larman.
Object Design Examples with GRASP (Ch. 18)
Use Case Model Operation Contracts Chapter 11 Applying UML and Patterns Craig Larman.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Review ♦ System sequence diagram ♦ Domain model
1 Lecture 6: Operation Contracts. 2 Overview  What is contract ?  The guidelines for writing contracts for the system operations.  Use Case realizations.
Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11.
Chapter 9 Applying UML and Patterns -Craig Larman
♦ Use Case Model  Detailled use case - Important  Use case diagram- Refactoring Use case diagram  > 1 Last Lectures.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Chapter 1 Applying UML and Patterns. The Need for Software Blueprints Knowing an object-oriented language and having access to a library is necessary.
Larman ch. 131 Use-Case Model : Adding Detail with operation contracts Larman ch. 13.
Object-Oriented Analysis and Design CHAPTER 10: SYSTEM SEQUENCE DIAGRAMS 1.
Drawing System Sequence Diagrams
COMP-350 Object-Oriented Analysis and Design Drawing System Sequence Diagrams Reference: Larman, Chapter 9.
System sequence diagrams
Chapter 10 Drawing System Sequence Diagrams
DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes.
Chapter 11 Operation Contracts. What They Are An operation is a specification of a transformation or query that an object may be called on to execute.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Operation Contracts. Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects.
Week 4 Operational Contracts Requirements to Design Logical Architecture.
Phase 6 Start: Saturday14 April End: Saturday 21 April
Domain Model A representation of real-world conceptual classes in a problem domain. The core of object-oriented analysis They are NOT software objects.
Larman chapter 101 Domain Model: Visualizing concepts Larman chapter 10.
GRASP: Designing Objects With Responsibilities
OO Methodology Elaboration Phase Iteration 1- Part 3.
1 Chapter 9: Operation Contracts Chapter 13 in Applying UML and Patterns Book.
Software Engineering 1 Object-oriented Analysis and Design Chap 31 More SSDs and Contracts.
Use-Case Model: Adding Detail with Operation Contracts.
1 Design Model Use-Case realizations with GRASP Larman chapter 17.
1 Object Oriented Analysis and Design System Events & Contracts.
OO Methodology Elaboration Phase Iteration 1- Part 2.
Object Design Examples with GRASP
Elaboration popo.
System Sequence Diagrams and Operation Contracts
Used to help understand requirements more completely
Chapter 1 OBJECT-ORIENTED ANALYSIS AND DESIGN
Unified Modeling Language
DESIGN MODEL: USE-CASE REALIZATIONS WITH GRASP PATTERNS
Operation Contracts Ch. 11.
Presentation transcript:

Use Case Model Operation Contracts Prepared By: Sumit Sharma and Sravanthi Gillala

Create contracts for system operations. Objectives

Unified Process Artifacts Business Model Requirements Design Domain Model Use Case Model Operation Contract Use Case Text System Sequence Diagrams Interaction Diagrams Supplementary Specifications Vision Glossary See Figure 11.1 in text for more detail

Why Contracts Use cases are the primary mechanism in the UP to describe system behavior, and are usually sufficient. However, sometimes a more detailed description of system behavior has value. Contracts for operations can help define system behavior.

Domain Model And Contracts A Domain Model is a visual representation of conceptual classes or real-world objects in a domain of interest. Contracts describe detailed system behavior in terms of state changes to objects in the Domain Model, after a system operation has executed.

Keep it Agile In many, or even most software development projects, operation contracts may be unnecessary. For an agile process, use them only when necessary to add additional detail and understanding.

System Operations and the System Interface Contracts may be defined for system operations – operations that the system as a black box offers in its public interface to handle incoming system events. System operations can be identified by discovering these system events. The entire set of system operations, across all use cases, defines the public system interface, viewing the system as a single component or class.

Example Contract: enterItem Operation: enterItem(itemID : ItemID, quantity : integer) Cross References: Use Cases: Process Sale Preconditions:There is a Sale Underway. Postconditions:-A SalesLineItem instance sli was created (instance creation) -sli was associated with the current Sale (association formed) -sli.quantity became quantity (attribute modification) -sli was associated with a ProductSpecification, based on itemID match (association formed) Contract CO2: enterItem

Contract Sections Operation: Name Of operation, and parameters. Cross References: (optional) Use cases this can occur within. Preconditions:Noteworthy assumptions about the state of the system or objects in the Domain Model before execution of the operation. Postconditions:-The state of objects in the Domain Model after completion of the operation.

Postconditions The postconditions describe changes in the state of objects in the Domain Model. Domain Model state changes include instances created, associations formed or broken, and attributes changed. Postconditions are not actions to be performed, during the operation; rather, they are declarations about the Domain Model objects that are true when the operation has finished.

The Spirit of Postconditions: The Stage and Curtain Express postconditions in the past tense, to emphasize they are declarations about a state change in the past. –(better) A SalesLineItem was created. –(worse) Create a SalesLineItem.

The Spirit of Postconditions: The Stage and Curtain Think about postconditions using the following image: The system and it’s objects are presented on a theatre stage. –Before the operation, take a picture of the stage. –Close the curtains on the stage, and apply the system operation –Open the curtains and take a second picture. –Compare the before and after pictures, and express as postconditions the changes in the state of the stage (A SalesLineItem was created…).

Writing Contracts Leads to Domain Model Updates New conceptual classes, attributes, or associations in the Domain Model are often discovered during contract writing. Enhance the Domain Model as you make new discoveries while thinking through the operation contracts.

Contracts vs. Use Cases The use cases are the main repository of requirements for the project. They may provide most or all of the detail necessary to know what to do in the design. If the details and complexity of required state changes are awkward to capture in use cases, then write operation contracts.

Contracts vs. Use Cases contd… If developers can understand what to do based on the use cases and ongoing (verbal) collaboration with a subject matter expert, avoid writing contracts. Operation contracts are uncommon. If a team is making contracts for every system operation: –the use cases are poorly done, or –there is not enough collaboration or access to a subject matter expert, or –the team is doing too much unnecessary documentation.

Guidelines: Contracts To make contracts: –Identify system operations from the SSDs. –For system operations that are complex and perhaps subtle in their own results, or which are not clear in the use case, construct a contract. –To describe the postconditions, use: - instance creation and deletion - attribute modification - associations formed and broken

The Most Common Mistake In Creating Contracts The most common problem in creating contracts is forgetting to include the forming of associations. Particularly, when new instances are created, it is very likely that associations to several objects need be established. Don’t forget to include all the associations formed and broken.

Contracts, Operations, and the UML The UML formally defines operations. To quote: –An operation is a specification of a transformation or query that an object may be called to execute [RJB99] An operation is an abstraction, not an implementation. By contrast, a method (in the UML) is an implementation of an operation.

Contracts, Operations, and the UML A UML operation has a signature (name and parameters), and also an operation specification, which describes the effects produced by executing the operation; the postconditions. A UML operation specification may not show an algorithm or solution, but only the state changes or effects of the operation.

Operation Contracts Expressed with the OCL Associated with the UML is a formal language called the Object Constraint Language (OCL) [WK99], which can be used to express constraints in models. The OCL defines an official format for specifying pre- and postconditions for operations, as demonstrated here: System::makeNewSale() pre: post: …

Programming Language Support for Contracts Some languages, such as Eiffel, have first- class support for invariants and pre- and postconditions. There are pre-processors that provide similar support in Java.

Operation Contracts Within the UP A pre- and postcondition contract is a well- known style to specify an operation. In UML, operations exist at many levels, from top level classes down to fine-grained classes. Operation specification contracts for the top level classes are part of the Use-Case Model.

Operation Contracts Within the UP Phases –Inception – Contracts are not needed during inception – they are too detailed. –Elaboration – If used at all, most contracts will be written during elaboration, when most use cases are written. Only write contracts for the most complex and subtle system operations.

New Systems Operations Let us create new system operations for a Point of Sale system to handle different forms of payment: –makeCreditPayment –makeCheckPayment

New System Operations (2) The system event and operation for cash payment in an earlier iteration was simply makePayment. As the payments are of different types the operation is renamed as makeCashPayment.

New System Operation Contracts System operation contracts are an optional requirements artifact that adds fine detail regarding the results of a system operation. The use case text itself is sufficient, at times. The contracts are not necessary.

New System Operation Contracts (2) The contracts bring value, on occasion, by their precise and detailed approach to identifying what happens when a complex operation is invoked on the system, in terms of state changes to objects defined in the Domain Model.

Contract: makeCreditPayment Operation: makeCreditPayment (creditAccountNumber, expiryDate) Cross References: Use Cases: Process Sale Preconditions: An underway sale exists and all items have been entered.

Contract: makeCreditPayment (2) Postconditions: –A credit payment pmt was created –pmt was associated with the current Sale sale a CreditCard cc was created. cc.number = creditAccountNumber, cc.expiryDate = expiryDate –cc was associated with pmt

Contract: makeCreditPayment (3) –a CreditPaymentRequest cpr was created –pmt was associated with cpr –a ReceivableEntry re was created –re was associated with the external AccountsReceivable –Sale was associated with the Store as a complete sale

makeCreditPayment There exists a postcondition indicating the association of a new receivable entry in accounts receivable. Although, this responsibility is outside the bounds of the NextGen system, the accounts receivable system is within the control of the business.

makeCreditPayment (2) The statement has thus been added as a correctness check. During testing, it is clear from this post- condition that the accounts receivable system should be tested for the presence of a new receivable entry.

Contract: makeCheckPayment Operation: makeCheckPayment (driversLicenseNumber) Cross References: Use Cases: Process Sale Preconditions: An underway sale exists and all items have been entered

Contract: makeCheckPayment (2) Postconditions: – a CheckPayment pmt was created –pmt was associated with the current Sale sale –a DriversLicense dl was created, dl.number = driversLicenseNumber –dl was associated with pmt

Contract: makeCheckPayment (3) –a CheckPaymentRequest cpr was created –pmt was associated with cpr –sale was associated with the Store as a completed sale

Summary Contracts describe detailed system behavior in terms of state changes to objects in the Domain Model after a system operation. Contracts have sections of Operations, Cross references, Preconditions and Postconditions. Postconditions are the most important section. Postconditions describe changes in the state of objects in the Domain Model. Domain Model state changes include instances created, associations formed or broken, and attributes changed.

Summary Writing Contracts leads to Domain Model updates. In UML, an operation is a specification of a transformation or query that an object may be called to execute. Most contracts will be written during elaboration, when most use cases are written. Only write contracts for the most difficult to understand or complicated system operations.

Bibliography Craig Larman, Applying UML and Patterns, 3rd Edition, Prentice Hall, 2002, ISBN