1 / 31

Advanced UML Class Diagrams

Advanced UML Class Diagrams. Objectives. To present the portions of the UML class diagram notation not already covered To present examples to illustrate the use of the notation To present heuristics for using the notation well. Topics. Generalization

chaney
Download Presentation

Advanced UML Class Diagrams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced UML Class Diagrams

  2. Objectives • To present the portions of the UML class diagram notation not already covered • To present examples to illustrate the use of the notation • To present heuristics for using the notation well

  3. Topics • Generalization • Abstract and concrete operations and classes • Interfaces • Feature visibility • Class and instance variables and operations • Aggregation and composition • Association classes and qualifiers • Other association adornments • More class diagram heuristics

  4. Generalization • Generalization is the UML relation that holds between one model element (the parent) and another (the child) when the child is a special type of the parent. • Represented by a hollow rectangle and lines • Rectangle attaches to the parent and lines to the children • Generalization is used in UML class diagrams to model inheritance.

  5. Generalization Example

  6. Generalization versus Association • Generalization is a relation between classes. • Associations represent relations on sets of class instances designated by the associated classes. • Generalization is not a kind of association. They • Never have multiplicities, • Never have rolenames, • Never have names (they already have a name: generalization).

  7. Abstract Operations and Classes • An abstract operation is an operation without a body; a concrete operation has a body. • An abstract class is a class that cannot be instantiated; a concrete class can be instantiated. • A class • Must be abstract if it has an abstract operation; • May be abstract even if it has no abstract operations.

  8. Using and Representing Abstract Classes and Operations • Abstract classes force their subclasses to implement certain operations. • Abstract classes are represented in UML by • Italicizing their names, • Stereotyping them «abstract» or • Giving them an {abstract} property. • Abstract operations are represented in UML by • Italicizing their specification or • Giving them an {abstract} property.

  9. Abstract Class and Operation Examples

  10. Interfaces A UML interface is named collection of public attributes and abstract operations. • Providedinterfaces—realized by a class or component and represented by • A ball (lollipop) symbol or • A stereotyped class icon with a realization connector • Requiredinterfaces—needed by a class or component and represented by • A socket symbol or • A dependency arrow to a ball symbol or • A dependency arrow to a stereotyped class icon

  11. Provided Interface Notations

  12. Required Interface Notations

  13. Module Assembly Notations

  14. UML Feature Visibility • Public—Visible anywhere that the class in which it appears is visible; denoted by +. • Package—Visible anywhere in the package containing the class in which it appears; denoted by ~. • Protected—Visible in the class in which it appears and all its sub-classes; denoted by #. • Private—Visible only in the class in which it appears; denoted by -.

  15. Feature Visibility Example

  16. Class and Instance Variables and Operations • An instance variable is an attribute whose value is stored by each instance of a class. • A class variable is an attribute whose value is stored only once and shared by all instances. • An instance operation must be called through an instance. • A class operation may be called through the class. • In UML class variables and operations are called static. • Indicated by underlining an attribute’s or operation’s specification

  17. Attribute and Operation Specification Examples

  18. Aggregation and Composition • The aggregation association represents the part-whole relation between classes. • Denoted by a solid diamond and lines • Diamond attaches to the aggregate (whole) while lines attach to the parts • May have all association adornments • The composition association is an aggregation association in which each part can be related to only one whole at a time. • Denoted by a hollow diamond and lines

  19. Aggregation and Composition Examples

  20. Problems with Aggregation • Often abused • Must be transitive: • (x)(y)(z)((Rxy • Ryz)  Rxz) • Often used for collection membership, which is not transitive • Aggregation, composition, and collection membership can be represented by plain associations.

  21. Association Classes • An association class represents a relation on instances of the classes is connects, and it holds data and behavior. • Association class connector is a dashed line • Connects class with an association line • There can be only one instance of an association class for each pair of instances of the associated classes. • If more instances are need, interpose a new class (a reified association).

  22. Association Class Example

  23. Association Qualifiers An association qualifier is one or more association attributes that, together with instances of the qualified class, pick out instances of an associated target class. • Represented by a box with association attributes and a line • Attributes have standard specifications except that no initial values are allowed • Box is attached to the qualified class • Line runs to the target class • Line can have association adornments

  24. Association Qualifier Examples

  25. Rolename Visibility • Associations are often implemented using references. • Rolename may be a reference attribute name • Rolenames may have visibility modifiers (+, #, ~, -). • Rolename visibility modifiers may be suppressed.

  26. Association Navigability An association between classes A and B is navigable from A to B if an instance of A can access an instance of B; otherwise it is non-navigable. • Navigability is denoted by adding an arrowhead to the association line in the navigation direction • Non-navigability is denoted by placing an x on the association line in the navigation direction • Navigability markers can be suppressed, so no markers means the diagram is silent on navigability

  27. Rolename Visibility and Navigability Example

  28. Class Diagram Heuristics 1 • Never place a name, rolenames, or multiplicities on a generalization connector. • Use the «abstract» stereotype and {abstract} property to indicate abstract classes and operations when drawing diagrams by hand; use italics when drawing diagrams on the computer. • Use the interface ball and socket symbols to abstract interface details and a stereotyped class symbol to show details.

  29. Class Diagram Heuristics 2 • Don’t italicize interface or operation names. • Show provided interfaces with the interface ball symbol or the stereotyped class symbol and a realization connector. • Show required interfaces with the interface socket symbol or dependency arrows to stereotyped class symbols or interface ball symbols. • Avoid aggregation and composition.

  30. Class Diagram Heuristics 3 • If aggregation or composition is used, check that the represented relation is transitive. • Use association classes when only a single association class instance is associated with each pair of instances of the associated classes; otherwise use a reified association. • Determine multiplicities involving a qualifier by considering qualified class instances and particular combinations of qualifier attribute values.

  31. Summary UML class diagrams have great expressive power: they are able to show • Generalization • Abstract operations and classes • Class and instance variables and operations • Interfaces and interface assemblies • Aggregation and composition associations • Association classes and quantifiers • Feature and rolename visibility • Navigability

More Related