Title: Chapter 5: UML Class Diagrams
1- Chapter 5 UML Class Diagrams
2- Objective
- Provide a reference for frequently used UML class
diagram notation.
35.1. Applying UML Common Class Diagram Notation
45.2. Definition Design Class Diagram
55.3. Definition Classifier
- A model element that describes behavioral and
structure features - Regular Class
- Interface
65.4. Ways to Show UML Attributes
- Ways to Show UML Attributes
- Attribute text notation,.
- Association line notation
- Both together
- Full format of the attribute text notation
- visibility name type multiplicity default
property-string
75.4. Ways to Show UML Attributes
85.4. Ways to Show UML Attributes
- Attribute-as-association line styles
- a navigability arrow pointing from the source to
target object, - a multiplicity at the target end, but not the
source end - a rolename only at the target end to show the
attribute name - no association name
95.4. Ways to Show UML Attributes
105.4. Ways to Show UML Attributes
- When to Use Attribute Text vs. Association Lines
for Attributes? - Use the attribute text notation for data type
objects - Use the association line notation for others
- Emphasize the connection between the class of
objects
115.4. Ways to Show UML Attributes
public class Register private int id
private Sale currentSale private Store
location //
125.4. Ways to Show UML Attributes
- The UML Notation for an Association End
135.4. Ways to Show UML Attributes
- public class Sale
- private ListltSalesLineItemgt lineItems
- new ArrayListltSalesLineItemgt()
- //
-
145.5. Note Symbols
- UML note or comment
- have no semantic impact
- UML constraint
- encased in braces ''
- method body
- the implementation of a UML operation
155.6. Operations and Methods
- Operations
- visibility name (parameter-list) return-type
property-string - getPlayer( name String ) Player exception
IOException - public Player getPlayer( String name ) throws
IOException - How to Show Methods in Class Diagrams?
- in interaction diagrams
- by the details and sequence of messages
- in class diagrams
- with a UML note symbol stereotyped with method
165.6. Operations and Methods
- Operation Issues in DCDs
- The create Operation
- Operations to Access Attributes
- often excluded (or filtered)
175.7. Keywords
- Textual adornment to categorize a model element
- Most are shown in guillemet ( )
- Some are shown in curly braces ( )
185.8. Stereotypes, Profiles, and Tags
- Stereotypes
- shown with guillemets symbols .
- represents a refinement of an existing modeling
concept - defined within a UML profile
- UML profiles
- a collection of related stereotypes, tags, and
constraints to specialize the use of the UML for
a specific domain or platform - Tags
- apply to the Stereotype element
- can be assigned values
195.8. Stereotypes, Profiles, and Tags
205.9. UML Properties and Property Strings
- Property
- a named value denoting a characteristic of an
element - Property string
- Format
- name1value1, name2value2
215.10. Generalization, Abstract Classes, Abstract
Operations
- Generalization
- A taxonomic relationship between a more general
classifier and a more specific classifier. - Each instance of the specific classifier is also
an indirect instance of the general classifier. - Abstract classes and operations
- shown either with an abstract tag
- italicizing the name
- Final classes and operations
- shown with the leaf tag
225.11. Dependency
- Dependency Relationship
- a client element has knowledge of another
supplier element - a change in the supplier could affect the client.
- Common Types
- having an attribute of the supplier type
- sending a message to a supplier the visibility
to the supplier could be - an attribute, a parameter variable, a local
variable, a global variable, or class visibility
(invoking static or class methods) - receiving a parameter of the supplier type
235.11. Dependency
- Used to depict following dependency between
objects - global
- parameter variable
- local variable
- static-method.
245.11. Dependency
public class Sale public void
updatePriceFor( ProductDescription description )
Money basePrice description.getPrice
() // //
255.11. Dependency
public class Foo public void doX()
System.runFinalization()
// //
265.11. Dependency
275.12. Interfaces
285.13. Composition Over Aggregation
- Aggregation
- a vague kind of association in the UML that
loosely suggests whole-part relationships. - Composition
- a strong kind of whole-part aggregation
- implies
- an instance of the part belongs to only one
composite instance at a time, - the part must always belong to a composite
- the composite is responsible for the creation and
deletion of its parts.
295.13. Composition Over Aggregation
305.14. Constraints
- UML Constraint
- restriction or condition on a UML element.
315.15. Qualified Association
- Qualified Association
- used to select an object (or objects) from a
larger set of related objects - based upon the qualifier key
325.16. Association Class
- Association Class
- treat an association as a class,
- model it with attributes, operations, and other
features
335.17. Singleton Classes
345.18. Template Classes and Interfaces
- templatized types,
- templates, parameterized types, and generics
355.18. Template Classes and Interfaces
- public class Board
- private ListltSquaregt squares
- new ArrayListltSquaregt()
- //
-
365.19. User-Defined Compartments
375.20. Active Class
385.21. What's the Relationship Between Interaction
and Class Diagrams?
39