31-05-2012, 02:04 PM
object oriented modeling and design
object oriented modeling and design.doc.doc (Size: 149 KB / Downloads: 53)
ADVANCED CLASS MODELING
Advanced Objects and Class Concepts:
Enumerations: A data type is a description of values. An enumeration is a data type has a finite set of values.
Example: accessPermission in file is an enumeration with possible values that include read and read-write.
Enumerations are also significant for an implementation. An enumeration is merely a list of values; generalization is a means for structuring the description of objects.
Introduce generalization only when at least one sub class has significant attributes, operations or associations that do not apply to the super class.
Example: you should not introduce a generalization for card, because most games do not differentiate the behavior of shades, clubs, hearts and diamonds.
Visibility:
refers to the ability of a method to reference a feature from another class and has the possible values of public, protected, private and package.
• Any method can freely access public features.
• Only methods of the containing class and its descendants via inheritance can access protected features.
• Only methods of the containing class can access private features.
• Methods of classes defined in the same package as the target class can access package features.
A genuine n-ary association:
Programmers use computer languages on projects. This n-ary association is an atomic unit and cannot be subdivided into binary associations without losing information. A programmer may know a language and work on a project, but might not use the language on the project. UML symbol for n-ary associations is a diamond with lines connecting to related classes.
Aggregation versus Association:
If 2 objects are tightly bound by a part whole relationship, it is an aggregation. If the 2 objects are usually considered as independent, even though they may often be linked, it is an association.
Some tests include:
• Would you use the phrase part of?
• Do some operations on the whole automatically apply to its part?
• Do some attribute values propagate from the whole to all or some parts?
• Is there an intrinsic asymmetry to the association, where one class is subordinate to the other?
Aggregations include bill of materials, part explosions and expansions of an object into constituent parts.
Aggregation is drawn like association, expect a small diamond indicates the assembly end.
Example: a lawn mower consists of one blade, one engine, many wheels and one deck.
Constraints on links:
Multiplicity is a constraint on the cardinality of a set. Multiplicity for an association restricts the number of objects related to a given object.
Multiplicity for an attribute specifies the number of values that are possible for each instantiation of an attribute.
Qualification also constrains an association. An association class is a class in every right. Example: it can have attributes and operations, participate in associations and participate in generalization.