1 / 13

COMP 6471 Software Design Methodologies

COMP 6471 Software Design Methodologies. Winter 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/comp647-w2006.html. Ch 11: Operation Contracts. Aim: Define system operations via contracts Operation Method Invariant Precondition Postcondition. Context within artefacts.

fineen
Télécharger la présentation

COMP 6471 Software Design Methodologies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP 6471Software Design Methodologies Winter 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/comp647-w2006.html

  2. Ch 11: Operation Contracts Aim: Define system operations via contracts Operation Method Invariant Precondition Postcondition

  3. Context within artefacts

  4. Context with SSDs

  5. UML Definitions Event A significant or noteworthy occurrence. Operation An operation is a specification of a transformation or query that an object may be called to execute. [RJB1999] Signature of an operation specifies the name, parameters, and return type (and exceptions thrown). Pre-conditions and post-conditions are UML constraints specified using OCL (Object Constraint Language). Method [A method is] the implementation of an operation. It specifies the algorithm or procedure associated with an operation [OMG 2003]

  6. Definitions Contract A contract specifies detailed changes, as a result of a system operation, to objects in the domain model using pre-conditions and post-conditions. Contract Format • Operation: name and parameters of operation. • Cross References: use cases that involve the operation. • Preconditions: noteworthy assumptions about the state of the system or object in the domain model before execution of the operation. • Postconditions: The state of objects in the domain model after completion of the operation. State A state is the condition of an object (or system) at a moment in time.

  7. Describing the State of a System Describe the objects in the system Describe the links (relationships) between the objects Describe the properties of each object (ie the state of the object) = the (abstract) values of the object attributes [as in a state machine]

  8. Example: State of CUWME Objects • users is the set of all User objects • roles is the set of all Role objects • projects is the set of all Project objects • Plus files, documents, … Links • u works_on p for User and Project objects • p owns d for Project and Document objects • d is_stored_as f for Document and File objects • … Object States • Document d has state “reviewed” • p.activity[3].status = “completed” • …

  9. Invariant of a System or Object Invariant Is a condition which is always true about the state of the system (or object) Note: the state is only defined in between execution of operations Hence, invariant only has to be true before and after each operation, not during an operation

  10. Example Invariants of CUWME(These depend on your abstractions/assumptions.) Each document is owned by exactly one project. Each project owns exactly one document. Each user has precisely one role in a given project. A user may only access documents owned by the projects that a user is working on. A document may be stored in more than one file. A file has only a single location. …

  11. Postcondition Definition 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. Note: postconditions are not actions to be performed during the operation They are the effect, ie observations about state of domain objects when the operation is finished. Ie, “what” not “how”

  12. Writing Postconditions Document • Instance creation and deletion “A SalesLineItem sli was created” • Attribute change of value “sli.quantity became quantity” Note: quantity is an operation parameter • Association links formed and broken “sli was linked to the current Sale” “sli was linked with a productDescription based on itemID match” Use past tense.

  13. Guidelines • Identify system operations from the SSDs. • For system operations that are complex and perhaps subtle in their results, or which are not clear in the use case, construct a contract. • To describe the postconditions, document • Instance creation and deletion • Attribute modification • Links formed and broken Use past tense for postconditions. Remember to document the forming of links!

More Related