Download presentation
Presentation is loading. Please wait.
Published byShannon Day Modified over 8 years ago
1
Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2005] CS 426 Senior Projects in Computer Science University of Nevada, Reno Department of Computer Science & Engineering
2
2 Relationships Links Associations Dependencies Inheritance and Polymorphism Generalization Class inheritance Polymorphism Advanced generalization
3
3 Relationships = semantic connections between modeling elements Links = connections between objects Associations = connections between classes Links are instances of associations
4
4 A link is a connection between objects that communicate via messages Links can be: Unidirectional, if only one object (the source) contains a reference to the other (the target). Bidirectional, if both objects have a reference to the other Object diagrams show objects and their relationships at some point in time. Thus, links are dynamic connections between objects
5
5 Example of object diagram, that shows objects, links, and roles. It also illustrates the oblique style of drawing paths in UML diagrams.
6
6 Example of unidirectional link The orthogonal style of drawing paths in UML diagrams
7
7 Associations are relationships between classes Links depend on associations, and instantiate them
8
8 The syntax for an association includes: Association name Role names Multiplicity Navigability
9
9 Multiplicity constrains the number of objects of a class that can be involved in a given relationship at any point in time
10
10 There is no default value for multiplicity in UML. If not specified, multiplicity is undecided
11
11 Multiplicity constraints encode business rules of the model It is important to “read the model as written”
12
12 Example of association hierarchy Example of association network
13
13 Navigability can be read “messages can only be sent in the direction of the arrow” Relationships without arrows are bidirectional Unidirectional associations reduce coupling between classes
14
14 One-to-one and one-to-many associations can be modeled using attributes
15
15 Many-to-many associations can lead to association classes Corresponding association class
16
16 However, many-to-many associations can also be modeled using regular classes
17
17 “A dependency is a relationship between two elements where a change to one element (the supplier) may affect or supply information needed by the other element (the client)” [Rumbaugh et al., The UML Reference Manual] Three types of dependency
18
18 Examples of different types of dependencies
19
19 The > dependencies are the most common type of dependency. They state that the client makes use of the supplier in some way. Java code for the above example
20
20 Abstraction dependencies are dependencies between model elements that are at different level of abstraction: >, >, > and >
21
21 Permission dependencies indicate the capability of one model element to access another model element. Examples of permission dependencies: > > (formerly >)
22
22 Generalization applies to all classifiers and to some other elements such as associations, states, and events
23
23 Example of class hierarchy
24
24 Example of overriding
25
25 Example of abstract classes and operations
26
26 In generalization hierarchies it is important to maintain a uniform level of abstraction at each level Incorrect example
27
27 Polymorphism means “many forms”. A polymorphic operation has several different implementations
28
28 Example of polymorphism “in action”
29
29 Object diagram with polymorphism
30
30 Another example of polymorphism
31
31 An example of generalization set
32
32 Constraints on generalization sets
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.