Top Banner
UML Structural Diagram Class Diagram
13

UML Structural Diagram

Dec 21, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: UML Structural Diagram

UML

Structural Diagram

Class Diagram

Page 2: UML Structural Diagram

Class Diagram

• To describe the types of objects in a system and their relationships.

• The classes in a class diagram represent both the main objects and or interactions in the application and the objects to be programmed.

• In the class diagram, classes are represented with boxes which contain three parts– The upper part holds the name of the class

– The middle part contains the attributes of the class, and

– The bottom part gives the methods or operations the class can take or undertake

Page 3: UML Structural Diagram

Example of a Class

Figure 1: Class Customer

Figure 2: Class BankAccount

Page 4: UML Structural Diagram

Relationships between Classes

• Used– during requirements analysis to model application domain

concepts

– during system design to model subsystems

– during object design to specify the detailed behavior and attributes of classes

• There are several relationships that might exist between classes. These includes:– Association

– Aggregation

– Generalization

Page 5: UML Structural Diagram

Association

• The association relationship is the most common relationship in a class diagram. It shows the relationship between instances of classes.

• For example, the class Order is associated with the class Customer.

• The multiplicity of the association denotes the number of objects that can participate in the relationship. For example, an Order object can be associated to only one customer, but a customer can be associated to many orders.

Figure 3: Example of Association relationship

Page 6: UML Structural Diagram

1-to-1 and 1-to-many Associations

Figure 5: 1-to-many association

Polygon

draw()

Point

x: Integer

y: Integer

*

Country

name:String

Capital

name:String

11

Figure 4: 1-to-1 association

Page 7: UML Structural Diagram

Many-to-many Associations

StockExchange Company

tickerSymbolLists

**

• A stock exchange lists many companies.• Each company is identified by a ticker symbol

Figure 6: Many-to-many association

Page 8: UML Structural Diagram

Aggregation

A variant of the "has a" or association relationship; aggregation is more specific than association. It is an association that represents a part-whole or part-of relationship

Graphically represented as a hollow diamond shape on the containing class

For example, we can think of Car as a whole entity and Car Wheel as part of the overall Car.

Figure 7: Example of Aggregation relationship

Page 9: UML Structural Diagram

cont.. Aggregation

• A solid diamond denotes composition: A strong form of aggregation where the life time of the component instances is controlled by the aggregate. That is, the parts don’t exist on their won (“the whole controls/destroys the parts”)

TicketMachine

ZoneButton

3

Figure 8: Example of Composition relationship

Page 10: UML Structural Diagram

Generalization

Figure 9:

Example of

Generalization

relationship

Page 11: UML Structural Diagram

cont..Generalization

Generalization is another name for inheritance or an "is a" relationship.

It refers to a relationship between two classes where one class is a

specialized version of another.

To model generalization on a class diagram, a solid line is drawn from the

child class (the class inheriting the behavior) with a closed, unfilled

arrowhead (or triangle) pointing to the super class .

For example, Corporate Customer and Personal Customer are types of

Customer. So the classes Corporate Customer and Personal Customer

would have a generalization relationship with the class Customer.

The children classes inherit the attributes and operations of the parent

class.

Page 12: UML Structural Diagram

Example of a Class Diagram

Figure 10: Example of a Class Diagram

Page 13: UML Structural Diagram

Example of a Class Diagram in EA