SE LAB KAIST CH3. Class Modeling Michael Blaha, James Rumbaugh Object-Oriented Modeling and Design with UML 2006-04-12 Tae-Hoon Song Software Engineering Lab 1
Contents Introduction Background Object and class concepts Link and association concepts Generalization and inheritance Navigation of class models Summary 2006-04-12 2/23
Introduction Object-oriented modeling and design Way of thinking about problems using models organized around real-world concepts Class modeling Describe the static data of objects and their relationships to one another Define each concept Present the corresponding UML notation 2006-04-12 3/23
Background Model Abstraction of something for purpose of understanding it before building it Viewpoints Class model Structure of objects in a system (class diagram) State model Aspects of an object that change over time (state diagram) Interaction model Objects in a system cooperate to achieve broader results (Use case/sequence/activity diagram) 2006-04-12 4/23
Object and class concepts (1/4) Object Concept, abstraction, or thing with identity Proper nouns or specific reference in problem description Class Group of objects with Same properties (attributes) Behavior (operations) Kinds of relationships Semantics 2006-04-12 5/23
Object and class concepts (2/4) Class diagrams Graphic notation for modeling classes and their relationships Object diagrams Graphic notation for individual objects and their relationships Rookie TaeHoon:Rookie SeokJoong:Rookie :Rookie Class Objects 2006-04-12 6/23
Object and class concepts (3/4) Value : piece of data Attribute : value for each object Operation Function or procedure that may be applied to or by objects in a class All objects in a class share the same operations Class Rookie name:string birthdate:date ( types ) TaeHoon:Rookie name= Tae Hoon ( attributes ) birthdate=6 Dec 1975 ( values ) Object enroll ( operation ) 2006-04-12 7/23
Object and class concepts (4/4) Summary of notation for class ClassName attributename1 : datatype1 = defaultvalue1 attributename2 : datatype2 = defaultvalue2 operationname1 ( argumentlist1 ) : resulttype1 operationname2 ( argumentlist2 ) : resulttype2 2006-04-12 8/23
Link and association concepts (1/8) Links and associations Link Physical or conceptual connection among objects Instance of an association Association Group of links with common structure and common semantics Set of potential links Links and associations : Verb in problem statements 2006-04-12 9/23
Link and association concepts (2/8) Links and associations (Cont d) Class diagram (Association) Rookie name OwnStock * * (Association name) Company name Object diagram (Link) Hoon:Rookie name= Hoon Joong:Rookie name= Joong Seok:Rookie name= Seok MS:Company name= MS SUN:Company name= SUN 2006-04-12 10/23
Link and association concepts (3/8) Multiplicity Constrain the number of related objects Assign a multiplicity to an association end Class diagram Husband name HasWife 1 1 (Multiplicity) name Wife Object diagram Hoon:Husband name= Hoon Seok:Husband name= Seok Lyn:Wife name= Lyn Hee:Wife name= Hee 2006-04-12 11/23
Link and association concepts (4/8) Association end names Each end of an association can have a name Convenience for traversing associations (Association end names) Person * employee employer WoksFor 0..1 Company employee Taehoon Seokjoong Youngseok employer MS MS IBM 2006-04-12 12/23
Link and association concepts (5/8) Ordering Indicate an ordered set of objects Provide an explicit order Permitted only for binary associations Screen 1 {ordered} VisibleOn * Window 2006-04-12 13/23
Link and association concepts (6/8) Bags and Sequences Permit multiple links for a pair of objects Bag Collection of elements with duplicates allowed Sequence Ordered bag Permitted only for binary associations Itinerary * {sequence} * Airport 2006-04-12 14/23
Link and association concepts (7/8) Association classes Derive identity from instances of the constituent classes Have attributes and operations Participate in associations User (Association class) * Authorization priority startsession (Dash line) Workstation 2006-04-12 15/23 * home * 1 (Participating in an association) Workstation
Link and association concepts (8/8) Qualified Associations Disambiguate the objects for a many association end Select among the target objects, reducing the effective multiplicity, from many to one 1 Bank * Account (Not qualified) accountnumber Bank accountnumber 1 0..1 Account (Qualified) (Qualifier) 2006-04-12 16/23
Generalization and inheritance (1/3) Definition Generalization Relationship between a class (the superclass) and one or more variations of the class (the subclass) Inheritance Each subclass has the features of its superclass Use of generalization Support for polymorphism Structure the description of objects Enable reuse of code 2006-04-12 17/23
Generalization and inheritance (2/3) Overriding features Refines and replaces (Subclass feature superclass feature) To specify behavior that depends on the subclass To tighten the specification of a feature To improve performance 2006-04-12 18/23
Generalization and inheritance (3/3) Vehicle engine door wheel displacement move (Generalization) Tank gun cannon fire move box bos bring Truck (Overriding Feature) jack bos lift Crane 2006-04-12 19/23
Navigation of class models (1/3) Navigation Express the behavior of navigating among classes Exercise a model and uncover hidden flaws and omissions Traverse the constructs in class models with OCL Object Constraint Language (OCL) Attributes Traverse from an object to an attribute value Vehicle. displacement 2006-04-12 20/23
Navigation of class models (2/3) Object Constraint Language (OCL) (Cont d) Operations Invoke an operation for an object Tank. Fire Operate on entire collections Vehicle. Tank. gun -> sum ( ) Simple association Traverse an association to a target end Person. employee Qualified association Make a more precise traversal Bank. accountnumber [060411] 2006-04-12 21/23
Navigation of class models (3/3) Object Constraint Language (OCL) (Cont d) Association class Find the constituent objects or the multiple links of an association class Generalization Traverse a generation hierarchy Filters Filter the objects in a set Vehicle. displacement -> select ( amount > cc 2000 ) 2006-04-12 22/23
Summary Class model Static data structure of objects and their relationships to one another Concepts Object : concept, abstraction, identified thing Class : group of objects (attribute, behavior, relations) Link and association : set of potential links Generalization : relationship between the superclass and the subclasses Navigation of class model : behavior of navigation among classes 2006-04-12 23/23
The end Thank you 2006-04-12 24/23