CS551 Behavior Models: Object Types and Operations (Chap. 3 of UML) Yugi Lee STB #555 (816) 235-5932 yugi@cstp.umkc.edu www.cstp.umkc.edu/~yugi CS551 - Lecture 6-2
Subtypes and Type Extension Class an object-oriented programming (OOP) construct (implementation of some objects) Type a specification of a set of objects Subclassing inheriting implementation with certain forms of overriding of implementation: Subtyping no overriding of specifications, only extension. CS551 - Lecture 6-2
Classes & Types CS551 - Lecture 6-2
Type Expression Subtype: Multiple Supertypes Type Exclusion Cow Mammal Multiple Supertypes Bat Mammal * Flier Type Exclusion TA1 * TA2 = Type Partitioning: TA = TA1+TA2 CS551 - Lecture 6-2
State Type A set of objects defined by a predicate Objects are classified based on a condition and define resultant properties they will have An employee is a person with an employer; employees have a salary and can get fired. CS551 - Lecture 6-2
State Chart Each state is a Boolean attribute The structure of states defines invariants across these attributes. States are mutually exclusive. can be nested inside a state. can be divided into concurrent sections CS551 - Lecture 6-2
CS551 - Lecture 6-2
State Transitions as Actions CS551 - Lecture 6-2
Translating State Transitions to Actions action Type::a1 pre: s1 & precond post: s2 & postcond action Pump::hangup pre: ready post: idle action Pump::pickup pre: idle post: ready CS551 - Lecture 6-2
State Charts of Specification Types CS551 - Lecture 6-2
State Charts of Specification Types action Drawing_Editor::select (shape:Shape) post: current_doc_contents -> forAll ( s | ((s.selected & s=shape)@pre ==> s.unselected) & ((s.unselected & s=shape)@pre ==> s.selected)) CS551 - Lecture 6-2
Sequence Expression S1 ; S2 S1 always precedes S2 S1 | S2 S1 or S2 Any number of repetitions of S1 S1 || S2 S1 concurrent with S2 CS551 - Lecture 6-2
The Meaning of Containment Containment represents a localized view, which is a state type of the common usage. CS551 - Lecture 6-2
Type Specifications: Summary An object’s behavior (or part of it) can be described with a type specification. A type specification is a set of action specifications A postcondition: a relationship between the states before and after any of its occurrences takes place. A precondition: when the associated postcondition is applicable. CS551 - Lecture 6-2