SlideShare a Scribd company logo
1 of 34
Operation Contracts
SS G514 OOAD
26-Nov-22
OOAD
1
System Sequence diagram [1]
26-Nov-22
OOAD
2
Use cases suggest how actors interact with the software
system
 An actor generates events to a system, requesting
some operation in response
 Example - when a cashier enters an item’s UPC, the
cashier requests the POST system to record that item
purchase. That request event initiates an operation
upon the system
 Desirable to isolate and illustrate the operations that
an actor requests to a system
System Sequence Diagram [2]
26-Nov-22
OOAD
3
 SSD Shows for a particular scenario of a use case, the
events that external actors generate, their order and
inter-system events
 A scenario of a use case is a particular instance or
realized path
 Should be done for a typical course of events of the use
case (usually for the most interesting ones)
System Events, Operations
26-Nov-22
OOAD
4
 System event - external input event generated by an
actor
 System operation - operation of the system that
executes in response
Recording System operations
26-Nov-22
OOAD
5
Set of all required systems operations is determined
by identifying the system events.
Operation(arg:ArgType=defaultvalue,,,):ReturnType(s)
 Examples: enterItem(UPC,quantity);
endSale();
makePayment(amount)
 UML notation -
26-Nov-22
OOAD
6
Objectives
 Create contracts for system operations.
Why Contracts
26-Nov-22
OOAD
7
 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.
 Describes what happens without explaining how.
Definition
26-Nov-22
OOAD
8
Contracts describe detailed system behavior in
terms of state changes to objects in the Domain
Model, after a system operation has executed.
System Operations and
the System Interface
26-Nov-22
OOAD
9
 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.
System operations handle input system
events
26-Nov-22
OOAD
10
System Contracts
26-Nov-22
OOAD
11
 Define responsibilities within the system.
 Operational contracts take the form of preconditions
and post-conditions
– Each module tests pre-conditions, then runs, then tests
post-conditions before returning to the caller
System Contracts
26-Nov-22
OOAD
12
 Operational contracts state what an operation
commits to achieving.
 Emphasizes what will happen, not how
 Describes changes in the state of the system –
Semantics
Contract Sections
26-Nov-22
OOAD
13
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.
Example Contract: enterItem
26-Nov-22
OOAD
14
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
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.
 postconditions support fine-grained detail and
specificity in declaring what the outcome of the
operation must be.
26-Nov-22
OOAD
15
How to Make a Contract
26-Nov-22
OOAD
16
 Identify operations from the system sequence diagram
 For each system operation, construct a contract
 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.
 The post-conditions describe changes in the state of
objects in the Domain Model.
 To describe post-conditions, use the following categories:
– Instance creation and deletion
– Attribute modification
– Associations formed and broken
enterltem Postconditions
 Instance Creation and Deletion:
After the itemID and quantity of an item have
been entered, what new object should have
been created? A SalesLineltem. Thus:
 A SalesLineltem instance sli was created (instance
creation).
Note the naming of the instance. This name
will simplify references to the new instance in
other post-condition statements.
26-Nov-22
OOAD
17
enterltem Postconditions
 Attribute Modification:
After the itemID and quantity of an item have
been entered by the cashier, what attributes of
new or existing objects should have been
modified? The quantity of the SalesLineltem
should have become equal to the quantity
parameter. Thus:
sli.quantity became quantity (attribute
modification).
26-Nov-22
OOAD
18
enterltem Postconditions
 Associations Formed and Broken:
After the itemID and quantity of an item have been
entered by the cashier, what associations between
new or existing objects should have been
formed or broken? The new SalesLineltem should
have been related to its Sale, and related to its
ProductSpeciflcation. Thus:
 . sli was associated with the current Sale (association
formed).
 . sli was associated with a ProductSpeciflcation, based on
ItemID match (association formed).
26-Nov-22
OOAD
19
POST Contract Process
26-Nov-22
OOAD
20
Writing Contracts Leads to
Domain Model Updates
26-Nov-22
OOAD
21
 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
26-Nov-22
OOAD
22
 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.
 If, just based on the use cases and through ongoing
collaboration with a subject matter expert, the
developers can comfortably understand what to do,
then avoid writing contracts.
Advice on Writing Contracts
 To make contracts:
1. Identify system operations from the SSDs.
2. For system operations that are complex and perhaps
subtle in their results, or which are not clear in the use
case, construct a contract.
3. To describe the postconditions, use the following
categories:
 instance creation and deletion
 attribute modification
 associations formed and broken
26-Nov-22
OOAD
23
Advice on Writing Contracts
26-Nov-22
OOAD
24
 Fill in the Operation section first
– Post-conditions section next
– Pre-conditions section last!
 Express post-conditions 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.
Advice on Writing Contracts
 Establish a memory between existing objects or
those newly created by defining the forming of an
association. For example, it is not enough that a new
SalesLineltem instance is created when the
enterltem operation occurs. After the operation is
complete, it should also be true that the newly
created instance was associated with Sale. Don’t
forget to include all the associations formed and broken.
26-Nov-22
OOAD
25
Example Contract
 makeNewSale:
Operation: makenewsale()
Cross Reference: Use Cases: Process Sale
Pre-condition: None
Post-condition: - A Sale instance s was created
(instance creation).
- s was associated with the Register
(association formed).
- Attributes of s were initialized.
On a project, all these particular postconditions are so
obvious from the use case that the makeNewSale
contract should probably not be written.
26-Nov-22
OOAD
26
Example Contract
 endSale:
Operation: endsale()
Cross Reference: Use Cases: Process Sale
Pre-condition: There is a sale underway
Post-condition: - Sale.isComplete became true
(attribute modification).
Changes in Domain Model:
26-Nov-22
OOAD
27
Example Contract
 makePayment:
Operation: makePayment( amount: Money)
Cross Reference: Use Cases: Process Sale
Pre-condition: There is a sale underway
Post-condition: - A Payment instance p was created
(instance creation).
- p.amountTendered became amount
(attribute modification).
- p was associated with the current
Sale (association formed).
- The current Sale was associated with
the Store (association formed); (to add it to
the historical log of completed sales)
26-Nov-22
OOAD
28
Summary : Contracts
26-Nov-22
OOAD
29
A contract describes detailed system behavior in
terms of state changes to objects in the domain
model.
 A contract is a system operation. It is offered in the
system’s public interface.
 One use case may require one or more system
operations (events) to complete a scenario.
 Most contracts will be written during elaboration
phase, when most use cases are written. Only write
contracts for the most difficult to understand or
complicated system operations.
Artifacts of Analysis
26-Nov-22
OOAD
30
Analysis Artifact Questions Answered
Use Cases What are the domain
processes?
Conceptual
model
What are the concepts and
terms?
System Sequence
diagrams
What are system events and
operations?
Contracts What are the semantics of
system operations?
Contract relationship to other artifacts
26-Nov-22
OOAD
31
Contract relationship to other
artifacts(1)
26-Nov-22
OOAD
32
REQUIREMENTS DESIGN
 Till now we have covered requirements analysis.
The requirements and object-oriented analysis has
focused on learning to do the right thing. that is,
understanding some of the outstanding goals for the
Next-Gen POS, and related rules and constraints.
 Now onwards we will start designing:
Design work will stress do the thing right; that is,
skillfully designing a solution to satisfy the
requirements for this iteration.
26-Nov-22
OOAD
33
REQUIREMENTS DESIGN
 In iterative development, a transition from primarily a
requirements focus to primarily a design and
implementation focus will occur in each iteration.
 It is natural and healthy to discover and change some
requirements during the design and implementation work
of the early iterations.
 During object design, a logical solution based on the
object-oriented paradigm is developed. The heart of this
solution is the creation of interaction diagrams, which
illustrate how objects collaborate to fulfill the
requirements. We can start designing class diagram
after or in parallel with interaction diagram.
26-Nov-22
OOAD
34

More Related Content

Similar to Lecture-System_Contracts.pptx

Software requirementspecification
Software requirementspecificationSoftware requirementspecification
Software requirementspecification
oshin-japanese
 
BoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docx
BoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docxBoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docx
BoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docx
jasoninnes20
 
Financial Analysis of Berlin Brandenburg AirportTotal of 3000 wo
Financial Analysis of Berlin Brandenburg AirportTotal of 3000 woFinancial Analysis of Berlin Brandenburg AirportTotal of 3000 wo
Financial Analysis of Berlin Brandenburg AirportTotal of 3000 wo
ChereCheek752
 
M03 2 Behavioral Diagrams
M03 2 Behavioral DiagramsM03 2 Behavioral Diagrams
M03 2 Behavioral Diagrams
Dang Tuan
 

Similar to Lecture-System_Contracts.pptx (20)

Software requirementspecification
Software requirementspecificationSoftware requirementspecification
Software requirementspecification
 
Scenario based methods
Scenario based methodsScenario based methods
Scenario based methods
 
BoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docx
BoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docxBoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docx
BoardSprintUser Story ScenarioDesignDevelopmentTestUAT Release1U .docx
 
Jar chapter 3
Jar chapter 3Jar chapter 3
Jar chapter 3
 
unit 3 software requirement and analysis-1.ppt
unit 3 software requirement and analysis-1.pptunit 3 software requirement and analysis-1.ppt
unit 3 software requirement and analysis-1.ppt
 
Financial Analysis of Berlin Brandenburg AirportTotal of 3000 wo
Financial Analysis of Berlin Brandenburg AirportTotal of 3000 woFinancial Analysis of Berlin Brandenburg AirportTotal of 3000 wo
Financial Analysis of Berlin Brandenburg AirportTotal of 3000 wo
 
03 - An introduction to hyperledger composer
03 - An introduction to hyperledger composer03 - An introduction to hyperledger composer
03 - An introduction to hyperledger composer
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19c
 
Day01 01 software requirement concepts
Day01 01 software requirement conceptsDay01 01 software requirement concepts
Day01 01 software requirement concepts
 
University of Gujrat Lahore sub Campus Documentation FYP
University of Gujrat Lahore sub Campus Documentation FYPUniversity of Gujrat Lahore sub Campus Documentation FYP
University of Gujrat Lahore sub Campus Documentation FYP
 
B2B add on implementation scenarios po. part I inbound edi
B2B add on implementation scenarios po. part I inbound ediB2B add on implementation scenarios po. part I inbound edi
B2B add on implementation scenarios po. part I inbound edi
 
Data Flow Diagram and USe Case Diagram
Data Flow Diagram and USe Case DiagramData Flow Diagram and USe Case Diagram
Data Flow Diagram and USe Case Diagram
 
Object oriented analysis &design - requirement analysis
Object oriented analysis &design - requirement analysisObject oriented analysis &design - requirement analysis
Object oriented analysis &design - requirement analysis
 
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdfDDD - 4 - Domain Driven Design_ Architectural patterns.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
 
Sap grc process control 10.0
Sap grc process control 10.0Sap grc process control 10.0
Sap grc process control 10.0
 
Ch7
Ch7Ch7
Ch7
 
Ch7
Ch7Ch7
Ch7
 
Chapter06
Chapter06Chapter06
Chapter06
 
Workload Management with MicroStrategy Software and IBM DB2 9.5
Workload Management with MicroStrategy Software and IBM DB2 9.5Workload Management with MicroStrategy Software and IBM DB2 9.5
Workload Management with MicroStrategy Software and IBM DB2 9.5
 
M03 2 Behavioral Diagrams
M03 2 Behavioral DiagramsM03 2 Behavioral Diagrams
M03 2 Behavioral Diagrams
 

Recently uploaded

Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
soniya singh
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
call girls in Dakshinpuri (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️
call girls in Dakshinpuri  (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️call girls in Dakshinpuri  (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️
call girls in Dakshinpuri (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
TusharBahuguna2
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
2-tool presenthdbdbdbdbddhdhddation.pptx
2-tool presenthdbdbdbdbddhdhddation.pptx2-tool presenthdbdbdbdbddhdhddation.pptx
2-tool presenthdbdbdbdbddhdhddation.pptx
suhanimunjal27
 
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
amitlee9823
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
anilsa9823
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
tbatkhuu1
 
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
amitlee9823
 

Recently uploaded (20)

Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
 
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
 
call girls in Dakshinpuri (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️
call girls in Dakshinpuri  (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️call girls in Dakshinpuri  (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️
call girls in Dakshinpuri (DELHI) 🔝 >༒9953056974 🔝 genuine Escort Service 🔝✔️✔️
 
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
 
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 
2-tool presenthdbdbdbdbddhdhddation.pptx
2-tool presenthdbdbdbdbddhdhddation.pptx2-tool presenthdbdbdbdbddhdhddation.pptx
2-tool presenthdbdbdbdbddhdhddation.pptx
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
 
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptx
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 

Lecture-System_Contracts.pptx

  • 1. Operation Contracts SS G514 OOAD 26-Nov-22 OOAD 1
  • 2. System Sequence diagram [1] 26-Nov-22 OOAD 2 Use cases suggest how actors interact with the software system  An actor generates events to a system, requesting some operation in response  Example - when a cashier enters an item’s UPC, the cashier requests the POST system to record that item purchase. That request event initiates an operation upon the system  Desirable to isolate and illustrate the operations that an actor requests to a system
  • 3. System Sequence Diagram [2] 26-Nov-22 OOAD 3  SSD Shows for a particular scenario of a use case, the events that external actors generate, their order and inter-system events  A scenario of a use case is a particular instance or realized path  Should be done for a typical course of events of the use case (usually for the most interesting ones)
  • 4. System Events, Operations 26-Nov-22 OOAD 4  System event - external input event generated by an actor  System operation - operation of the system that executes in response
  • 5. Recording System operations 26-Nov-22 OOAD 5 Set of all required systems operations is determined by identifying the system events. Operation(arg:ArgType=defaultvalue,,,):ReturnType(s)  Examples: enterItem(UPC,quantity); endSale(); makePayment(amount)  UML notation -
  • 7. Why Contracts 26-Nov-22 OOAD 7  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.  Describes what happens without explaining how.
  • 8. Definition 26-Nov-22 OOAD 8 Contracts describe detailed system behavior in terms of state changes to objects in the Domain Model, after a system operation has executed.
  • 9. System Operations and the System Interface 26-Nov-22 OOAD 9  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.
  • 10. System operations handle input system events 26-Nov-22 OOAD 10
  • 11. System Contracts 26-Nov-22 OOAD 11  Define responsibilities within the system.  Operational contracts take the form of preconditions and post-conditions – Each module tests pre-conditions, then runs, then tests post-conditions before returning to the caller
  • 12. System Contracts 26-Nov-22 OOAD 12  Operational contracts state what an operation commits to achieving.  Emphasizes what will happen, not how  Describes changes in the state of the system – Semantics
  • 13. Contract Sections 26-Nov-22 OOAD 13 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.
  • 14. Example Contract: enterItem 26-Nov-22 OOAD 14 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
  • 15. 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.  postconditions support fine-grained detail and specificity in declaring what the outcome of the operation must be. 26-Nov-22 OOAD 15
  • 16. How to Make a Contract 26-Nov-22 OOAD 16  Identify operations from the system sequence diagram  For each system operation, construct a contract  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.  The post-conditions describe changes in the state of objects in the Domain Model.  To describe post-conditions, use the following categories: – Instance creation and deletion – Attribute modification – Associations formed and broken
  • 17. enterltem Postconditions  Instance Creation and Deletion: After the itemID and quantity of an item have been entered, what new object should have been created? A SalesLineltem. Thus:  A SalesLineltem instance sli was created (instance creation). Note the naming of the instance. This name will simplify references to the new instance in other post-condition statements. 26-Nov-22 OOAD 17
  • 18. enterltem Postconditions  Attribute Modification: After the itemID and quantity of an item have been entered by the cashier, what attributes of new or existing objects should have been modified? The quantity of the SalesLineltem should have become equal to the quantity parameter. Thus: sli.quantity became quantity (attribute modification). 26-Nov-22 OOAD 18
  • 19. enterltem Postconditions  Associations Formed and Broken: After the itemID and quantity of an item have been entered by the cashier, what associations between new or existing objects should have been formed or broken? The new SalesLineltem should have been related to its Sale, and related to its ProductSpeciflcation. Thus:  . sli was associated with the current Sale (association formed).  . sli was associated with a ProductSpeciflcation, based on ItemID match (association formed). 26-Nov-22 OOAD 19
  • 21. Writing Contracts Leads to Domain Model Updates 26-Nov-22 OOAD 21  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.
  • 22. Contracts vs. Use Cases 26-Nov-22 OOAD 22  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.  If, just based on the use cases and through ongoing collaboration with a subject matter expert, the developers can comfortably understand what to do, then avoid writing contracts.
  • 23. Advice on Writing Contracts  To make contracts: 1. Identify system operations from the SSDs. 2. For system operations that are complex and perhaps subtle in their results, or which are not clear in the use case, construct a contract. 3. To describe the postconditions, use the following categories:  instance creation and deletion  attribute modification  associations formed and broken 26-Nov-22 OOAD 23
  • 24. Advice on Writing Contracts 26-Nov-22 OOAD 24  Fill in the Operation section first – Post-conditions section next – Pre-conditions section last!  Express post-conditions 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.
  • 25. Advice on Writing Contracts  Establish a memory between existing objects or those newly created by defining the forming of an association. For example, it is not enough that a new SalesLineltem instance is created when the enterltem operation occurs. After the operation is complete, it should also be true that the newly created instance was associated with Sale. Don’t forget to include all the associations formed and broken. 26-Nov-22 OOAD 25
  • 26. Example Contract  makeNewSale: Operation: makenewsale() Cross Reference: Use Cases: Process Sale Pre-condition: None Post-condition: - A Sale instance s was created (instance creation). - s was associated with the Register (association formed). - Attributes of s were initialized. On a project, all these particular postconditions are so obvious from the use case that the makeNewSale contract should probably not be written. 26-Nov-22 OOAD 26
  • 27. Example Contract  endSale: Operation: endsale() Cross Reference: Use Cases: Process Sale Pre-condition: There is a sale underway Post-condition: - Sale.isComplete became true (attribute modification). Changes in Domain Model: 26-Nov-22 OOAD 27
  • 28. Example Contract  makePayment: Operation: makePayment( amount: Money) Cross Reference: Use Cases: Process Sale Pre-condition: There is a sale underway Post-condition: - A Payment instance p was created (instance creation). - p.amountTendered became amount (attribute modification). - p was associated with the current Sale (association formed). - The current Sale was associated with the Store (association formed); (to add it to the historical log of completed sales) 26-Nov-22 OOAD 28
  • 29. Summary : Contracts 26-Nov-22 OOAD 29 A contract describes detailed system behavior in terms of state changes to objects in the domain model.  A contract is a system operation. It is offered in the system’s public interface.  One use case may require one or more system operations (events) to complete a scenario.  Most contracts will be written during elaboration phase, when most use cases are written. Only write contracts for the most difficult to understand or complicated system operations.
  • 30. Artifacts of Analysis 26-Nov-22 OOAD 30 Analysis Artifact Questions Answered Use Cases What are the domain processes? Conceptual model What are the concepts and terms? System Sequence diagrams What are system events and operations? Contracts What are the semantics of system operations?
  • 31. Contract relationship to other artifacts 26-Nov-22 OOAD 31
  • 32. Contract relationship to other artifacts(1) 26-Nov-22 OOAD 32
  • 33. REQUIREMENTS DESIGN  Till now we have covered requirements analysis. The requirements and object-oriented analysis has focused on learning to do the right thing. that is, understanding some of the outstanding goals for the Next-Gen POS, and related rules and constraints.  Now onwards we will start designing: Design work will stress do the thing right; that is, skillfully designing a solution to satisfy the requirements for this iteration. 26-Nov-22 OOAD 33
  • 34. REQUIREMENTS DESIGN  In iterative development, a transition from primarily a requirements focus to primarily a design and implementation focus will occur in each iteration.  It is natural and healthy to discover and change some requirements during the design and implementation work of the early iterations.  During object design, a logical solution based on the object-oriented paradigm is developed. The heart of this solution is the creation of interaction diagrams, which illustrate how objects collaborate to fulfill the requirements. We can start designing class diagram after or in parallel with interaction diagram. 26-Nov-22 OOAD 34