CHAPTER 4 ADVANCED CLASS MODELING ADVANCED CLASS MODELING

  • Slides: 12
Download presentation
CHAPTER 4 ADVANCED CLASS MODELING

CHAPTER 4 ADVANCED CLASS MODELING

ADVANCED CLASS MODELING � Advanced Objects and Class Concepts � Association Ends � N-ary

ADVANCED CLASS MODELING � Advanced Objects and Class Concepts � Association Ends � N-ary Associations � Aggregation � Abstract Class � Multiple Inheritance � Metadata � Reification � Constraints � Derived Data � Packages

4. 5 ABSTRACT CLASS Abstract class is a class that has no direct instances

4. 5 ABSTRACT CLASS Abstract class is a class that has no direct instances but whose descendant classes have direct instance � Concrete Class is a class that is instantiable; it can have direct instances; can be leaf class in inheritance tree � Its good idea to avoid concrete superclass � All super classes are abstract and all leaf subclasses are concrete � Can eliminate concrete superclasses by introducing an “other subclass” � UML Notation: Class name in Italics � Keyword {abstract } before/after the name �

4. 6 MULTIPLE INHERITANCE � � � Permit a class to have more than

4. 6 MULTIPLE INHERITANCE � � � Permit a class to have more than one class Advantage – Power in specifying classes & an increased opportunity for reuse Disadvantage – Loss of conceptual & implementation simplicity Concept – Generalization – Multiple Generalization Language – Inheritance – Multiple Inheritance

4. 6. 1 KINDS OF MULTIPLE INHERITANCE � Complete � Disjoint � Overlapping �

4. 6. 1 KINDS OF MULTIPLE INHERITANCE � Complete � Disjoint � Overlapping � Incomplete � UML Notation: Dotted Line cutting across the affected generalization with a constraint in {} � Refer Book for diagram

4. 6. 2 MULTIPLE CLASSIFICATION � One Instance to participate in two overlapping classes

4. 6. 2 MULTIPLE CLASSIFICATION � One Instance to participate in two overlapping classes � One VTU Professor taking class in IIT � OO Languages handles it poorly, so workarounds will solve the same

4. 6. 3 WORKAROUNDS Delegation using composition of Parts � Inherit the most important

4. 6. 3 WORKAROUNDS Delegation using composition of Parts � Inherit the most important class and delegate the rest � Nested generalization � Issues to be considered � Superclass of equal importance – I � Dominant Superclass – II & III � Few Subclasses – III � Sequencing generalization sets - III � Large quantities of Code – Try to avoid - Dupe code & spoil OO Concepts � Identity – III Preserve �

4. 7 META DATA � Class Definition is a meta data � Describes the

4. 7 META DATA � Class Definition is a meta data � Describes the data � Computer languages implements meta data heavily

4. 8 REIFICATION � Promotion of something that is not an object into an

4. 8 REIFICATION � Promotion of something that is not an object into an object � Useful to promote attributes, methods, constraints and control information into objects, so that it can be manipulated and described as data � Eg : Type cast in Programming lang � Association Class “Works For”

4. 9 CONSTRAINTS � � A boolean conditions involving model elements like objects, generalization

4. 9 CONSTRAINTS � � A boolean conditions involving model elements like objects, generalization set, links Can be expressed using OCL Constraints on objects Constraints on Generalization Set � � Constraints on Links � � Multiplicity; Qualification; Association Class; Constraints on Association End � � Semantics of generalization imply certain structural constraints – Disjoint; Overlapping; Complete; Incomplete Ordered; Subset; Bags; Sequence Use of Constraint � � Measuring the quality of the class model “Good” Class Model Captures Important Constraints

4. 10 DERIVED DATA � Function of one or more elements – derived attribute,

4. 10 DERIVED DATA � Function of one or more elements – derived attribute, association , classes � A class model should generally distinguish independent base attributes from dependent derived attribute � Use derived elements for implementation where they are compelling � UML Notation – A slash in the front of the element

4. 11 PACKAGES � Group of elements with a common theme � Packages are

4. 11 PACKAGES � Group of elements with a common theme � Packages are to organize large models so that the reader can understand portions of the model at a time, rather than having to deal with the whole model at once � Tips for devising packages � Carefully delineate each packages scope � Define each class in a single package