Unit 2 Part 2
Unit 2 Part 2
Role
• When a class participates in an association, it has a specific role that it plays in
that relationship; a role is just the face the class at the far end of the association
presents to the class at the near end of the association. You can explicitly name
the role a class plays in an association. The role played by an end of an
association is called an end name (in UML1, it was called a role name). the class
Person playing the role of employee is associated with the class Company playing
the role of employer.
Multiplicity
• An association represents a structural relationship among objects. In many
modeling situations, it's important for you to state how many objects may be
connected across an instance of an association. This "how many" is called the
multiplicity of an association's role. It represents a range of integers specifying
the possible size of the set of related objects.
• The number of objects must be in the given range. You can show a multiplicity of
exactly one (1), zero or one (0..1), many (0..*), or one or more (1..*). You can give
an integer range (such as 2..5). You can even state an exact number (for example,
3, which is equivalent to 3..3).
Aggregation
• A plain association between two classes represents a structural
relationship between peers, meaning that both classes are
conceptually at the same level, no one more important than the
other. Sometimes you will want to model a "whole/part" relationship,
in which one class represents a larger thing (the "whole"), which
consists of smaller things (the "parts"). This kind of relationship is
called aggregation, which represents a "has-a" relationship.
Common Modeling Techniques
i) Modeling Simple Dependencies
ii) Modeling Single Inheritance
iii) Modeling Structural Relationships
i) Modeling Simple Dependencies
• Create a dependency pointing from the class with the operation to
the class used as a parameter in the operation.
i) Modeling Single Inheritance
iii)Modeling Structural Relationships
3. Common Mechanisms:
Terms and Concepts
• A note is a graphical symbol for rendering constraints or comments
attached to an element or a collection of elements. Graphically, a
note is rendered as a rectangle with a dog-eared corner, together
with a textual or graphical comment.
• A stereotype is an extension of the vocabulary of the UML, allowing
you to create new kinds of building blocks similar to existing ones but
specific to your problem. Graphically, a stereotype is rendered as a
name enclosed by guillemets (French quotation marks of the form «
»), placed above the name of another element.
• A tagged value is a property of a stereotype, allowing you to create
new information in an element bearing that stereotype. Graphically, a
tagged value is rendered as a string of the form name = value within a
note attached to the object.
• A constraint is a textual specification of the semantics of a UML
element, allowing you to add new rules or to modify existing ones.
Graphically, a constraint is rendered as a string enclosed by brackets{}
and placed near the associated element or connected to that element
or elements by dependency relationships. As an alternative, you can
render a constraint in a note.
• Stereotypes (Represents new elements)
• Tagged values (Represents new attributes)
• Constraints (Represents the boundaries)
Notes
• A note that renders a comment has no semantic impact, meaning
that its contents do not alter the meaning of the model to which it is
attached. This is why notes are used to specify things like
requirements, observations, reviews, and explanations, in addition to
rendering constraints.
• A note may contain any combination of text or graphics
Other Adornments
• Adornments are textual or graphical items that are added to an
element's basic notation and are used to visualize details from the
element's specification.
Stereotypes
• The UML provides a language for structural things, behavioral things,
grouping things, and notational things. These four basic kinds of
things address the overwhelming majority of the systems you'll need
to model.
• In its simplest form, a stereotype is rendered as a name enclosed by
guillemets (for example,«name») and placed above the name of
another element.
Tagged Values
• Every thing in the UML has its own set of properties: classes have
names, attributes, and operations; associations have names and two
or more ends, each with its own properties; and so on. With
stereotypes, you can add new things to the UML; with tagged values,
you can add new properties to a stereotype.
Constraints
• Everything in the UML has its own semantics. Generalization (usually,
if you know what's good for you) implies the Liskov substitution
principle, and multiple associations connected to one class denote
distinct relationships. With constraints, you can add new semantics or
extend existing rules. A constraint specifies conditions that a run-time
configuration must satisfy to conform to the model.
Common Modeling Techniques
i) Modeling Comments
ii) Modeling New Properties
iii) Modeling New Semantics
i) Modeling Comments
• Put your comment as text in a note and place it adjacent to the element to
which it refers. You can show a more explicit relationship by connecting a
note to its elements using a dependency relationship.
• Remember that you can hide or make visible the elements of your model
as you see fit. This means that you don't have to make your comments
visible everywhere the elements to which it is attached are visible. Rather,
expose your comments in your diagrams only insofar as you need to
communicate that information in that context.
• If your comment is lengthy or involves something richer than plain text,
consider putting your comment in an external document and linking or
embedding that document in a note attached to your model.
ii) Modeling New Properties
• First, make sure there's not already a way to express what you want
by using basic UML.
• If you re convinced there's no other way to express these semantics,
define a stereotype and add the new properties to the stereotype.
The rules of generalization applytagged values defined for one kind of
stereotype apply to its children.
iii) Modeling New Semantics
• First, make sure there's not already a way to express what you want
by using basic UML.
• If you re convinced there's no other way to express these semantics,
write your new semantics in a constraint placed near the element to
which it refers. You can show a more explicit relationship by
connecting a constraint to its elements using a dependency
relationship.
4. Diagrams
4. Diagrams
Terms and Concepts
• A system is a collection of subsystems organized to accomplish a purpose
and described by a set of models, possibly from different viewpoints.
• A subsystem is a grouping of elements, some of which constitute a
specification of the behavior offered by the other contained elements.
• A model is a semantically closed abstraction of a system, meaning that it
represents a complete and self-consistent simplification of reality, created
in order to better understand the system. In the context of architecture,
• A view is a projection into the organization and structure of a system's
model, focused on one aspect of that system.
• A diagram is the graphical presentation of a set of elements, most often
rendered as a connected graph of vertices (things) and arcs (relationships).
Terms and Concepts
• In modeling real systems, no matter what the problem domain, you'll
find yourself creating the same kinds of diagrams, because they
represent common views into common models. Typically, you'll view
the static parts of a system using one of the following diagrams.
1. Class diagram
2. Component diagram
3. Composite structure diagram
4. Object diagram
5. Deployment diagram
6. Artifact diagram
Terms and Concepts
• You'll often use five additional diagrams to view the dynamic parts of
a system.
1. Use case diagram
2. Sequence diagram
3. Communication diagram
4. State diagram
5. Activity diagram
Terms and Concepts
Structural Diagrams
• The UML's structural diagrams exist to visualize, specify, construct,
and document the static aspects of a system.
• The UML's structural diagrams are roughly organized around the
major groups of things you'll find when modeling a system.
1.Class diagram Classes, interfaces, and collaborations
3.Collaboration Focuses on the structural organization of objects that send and receive
diagram messages