7 - University of Mississippi

Download Report

Transcript 7 - University of Mississippi

THE UNIVERSITY OF MISSISSIPPI
Software Component
Specification
Using Design by Contract
Yi Liu
H. Conrad Cunningham
Software Architecture Research Group
Dept. of Computer & Information Science
University of Mississippi
THE UNIVERSITY OF MISSISSIPPI
Project
Development of component software course
• systematic, technology-independent methods
–
–
–
–
object-oriented analysis and design techniques
design by contract
design patterns
Unified Modeling Language (UML)
• Java 2 Enterprise Edition (J2EE)
7/18/2015
2
THE UNIVERSITY OF MISSISSIPPI
What is a Component?
Clemens Szyperski:
A software component is a unit of
composition with a contractually specified
interface and explicit context dependencies
only. A software component can be deployed
independently and is subject to composition
by third parties.
7/18/2015
3
THE UNIVERSITY OF MISSISSIPPI
Software Component
input
output
input
output
interface
inner
component
7/18/2015
Component1
Component2
4
THE UNIVERSITY OF MISSISSIPPI
UML Components Methodology
Requirements Specification
• Use case model
• Domain model
7/18/2015
5
THE UNIVERSITY OF MISSISSIPPI
Core Types and Interfaces
<<interface type>>
Interface1
<<core>>
Coretype1
<<type>>
Type2
<< type >>
Type1
<<core>>
Coretype2
7/18/2015
6
THE UNIVERSITY OF MISSISSIPPI
UML Components Methodology
Design Specification
• Component architecture
• Component specifications
– interface specifications
7/18/2015
7
THE UNIVERSITY OF MISSISSIPPI
Design by Contract
• Precisely specify WHAT an interface must do
• Separate consideration of HOW implemented
Helps develop components that are
• Reliable
• Pluggable in a component framework
7/18/2015
8
THE UNIVERSITY OF MISSISSIPPI
Design by Contract
Semantics of Operations
• Preconditions for correct use
• Postconditions for correct result
Retrieve record with a given key from a table component
pre: record with given key exists in table
post: record with given key returned
7/18/2015
9
THE UNIVERSITY OF MISSISSIPPI
Design by Contract
Invariants
• Conditions for correct implementation
• Constraints on component instance’s state
Invariant for a table component:
component instance contains at most one record with
any particular value of the key
7/18/2015
10
THE UNIVERSITY OF MISSISSIPPI
Design by Contract
Information Model
Abstract state of object implementing interface
<<interface>>
ITableMgt
<<core>>
Table
7/18/2015
<<type>>
Record
<<type>> Key
11
THE UNIVERSITY OF MISSISSIPPI
Interface Specification
• Operations (needed to implement use cases)
– signature
– precondition
– postcondition
• Invariants
• Information model (derived from domain
model)
7/18/2015
12
THE UNIVERSITY OF MISSISSIPPI
Pluggability
Component with interface C conforms to plug point
with interface P where R is refinement invariant:
• P.signatures subset of C.signatures
• For each operation m in P.signatures
– P.op(m).pre & P.inv & R implies C.op(m).pre
– C.op(m).post & C.inv & R implies P.op(m).post
• C.inv & R implies P.inv
7/18/2015
13
THE UNIVERSITY OF MISSISSIPPI
Course Registration System
<<interface type>>
IPersonMgt
<<type>>
Student
<<core>>
Person
<<type>>
Instructor
<<type>>
StudentSchedule
<<core>>
Term
<<type>>
InstructorSchedule
<<type>>
Section
<<core>>
Course
7/18/2015
14
THE UNIVERSITY OF MISSISSIPPI
Operation Precondition in OCL
IPersonMgt::makeStudentSchedule ( in sectioninfo:sectionDetails,
in studentinfo:studentDetails, out schedule:scheduleDetails ) :
Boolean
Pre:
----------------section and student information are valid
Course -> exists(c|c.id = sectioninfo.courseId) and
Term-> exists(t|t.termNo = sectioninfo.termNo) and
Section -> exists (se|se.sectionNo = sectioninfo.sectionNo) and
Person-> exists(z|id = studentinfo.studentID) and
Student -> exists(y|id = studentinfo.studentID)
7/18/2015
15
THE UNIVERSITY OF MISSISSIPPI
Operation Postcondition in OCL
Post:
Result implies
StudentSchedule@pre ->
forall(x|x.scheduleRef <> schedule.scheduleRef)
and
let s = (StudentSchedule – StudentSchedule@pre) ->
asSequence -> first in
s.schedule.scheduleRef = schedule.scheduleRef and
s.schedule.id = schedule.id and
schedule.id = studentInfo.studentID and
s.schedule.section = schedule.section and
schedule.section = sectioninfo.section
7/18/2015
16
THE UNIVERSITY OF MISSISSIPPI
Summary
• Developing component software course
• Using UML-based methods for specifying
system models
• Applying Design by Contract to state
operation semantics
7/18/2015
17
THE UNIVERSITY OF MISSISSIPPI
Future Work
• Refine methods for nested components
• Investigate concept of pluggability
• Specify user interfaces of components
7/18/2015
18
THE UNIVERSITY OF MISSISSIPPI
Acknowledgements
• Supported by Acxiom Corporation
• Principal Investigator Conrad Cunningham,
[email protected]
• Research Assistants Yi Liu, Pallavi Tadepalli,
MingXian Fu, and Jian Li
7/18/2015
19