3 Unit Questions
3 Unit Questions
Explain
Depending on the context, classes in a class diagram can represent the main objects, interactions
in the application
Basic components of a class diagram
A class represents an object or a set of objects that share a common structure and behavior.
They're represented by a rectangle that includes rows of the class name, its attributes, and its
operations. When you draw a class in a class diagram, you're only required to fill out the top
row—the others are optional.
Name: The first row in a class shape.
o Attributes: The second row in a class shape. Each attribute of the class is displayed on a
separate line.
o Methods: The third row in a class shape. Also known as operations, methods are displayed
in list format with each operation on its own line.
Dependency
Generalization
Association
Realization
Dependency
Specifying a change in the specification of one thing may affect another thing, but not
necessarily the reverse
Graphically rendered as a dashed line
There are eight stereotypes that apply to dependency relationships among classes and
objects in class diagrams
Use The semantics of the source element depends on the semantics of the public part
of the target
Examples:
<<bind>>
<<derive>>
<<friend>>
<<instanceOf>>
<<instantiate>>
<<powertype>>
<<refine>>
<<use>>
Access - Source package is granted the right to reference the elements of the target
package
Import - A kind of access, but only public content
<<access>>
<<import>>
<<extend>>
<<include>>
Examples:
<<become>>
<<call>>
<<copy>>
In the context of organizing the elements of your system into subsystem and model
Example:
There are four standard constraints that apply to the generalization relationship:
The four basic adornments for an association relationship are: name, role at each end of the
association, multiplicity at each end of the association and aggregation. Over these basic
features, there are other advanced features like: navigation, visibility, qualification,
composition and association classes.
Navigation Given an association between two things, we can navigate from one thing to
another and vice versa. By default the navigation of an association is bidirectional. In some
cases we may need to navigate in only direction. For example, given an order, we can get the
details of the products in the order. But, if we consider a product, there might be no need to
know about the order to which it belongs.
Visibility Given an association, we can navigate from one object to another. However, in some
situations we may want to limit the visibility (access) of an object to the objects outside the
association relationship.
To limit the visibility of an object, we can use the visibility specifiers: public (+), private (-)
and protected (#). For example, a usergroup object can access the user object and an user
object can access the password. If, private visibility is specified for the password object, the
usergroup object cannot access the password of the user object.
Qualification In binary associations, where two classes are connected together, if one object
of a class has to identify a set of instances of another class, we can use qualifiers. A qualifier
is a set of attributes of an association which is used to identify a set of instances of a class.
Each qualifier is represented with a name and type in a rectangle box at the qualified end of
the association relationship. For example, a bank object is able to recognize the person
(account holder) based on the account number. So, account number is the qualifier which is
used to identify an account holder.
Realization is graphically represented as dashed line with a hollow arrow head pointing
towards the classifier which provides the specification.
Write and explain terms and concepts of interfaces, types and roles. [7M]
Interface
An interface is a collection of operations that are used to specify a service of a class or a
component. Graphically, an interface is rendered(represented) as a circle; in its expanded
form, an interface may be rendered as a stereotyped class(a class with sterotype interface).
An interface name must be unique within its enclosing package. Two naming mechanism; a
simple name(only name of the interface)as shown
Figure:1
a path name is the interface name prefixed by the name of the package in which that interface
lives represented in Figure: 2.
Figure:2
To distinguish an interface from a class, prepend an ‗I‘ to every interface name. Operations in
an interface may be adorned with visibility properties, concurrency properties, stereotypes,
tagged values, and constraints. Interface don‘t have attributes. Interfaces span model
boundaries and it does‘nt have direct instances.
Interface relationships
Type
A type is a stereotype of a class used to specify a domain of objects, together with the
operations (but not the methods) applicable to the object of that type. To distinguish a type
from an interface or a class, prepend a ‗T‘ to every type. Stereotype type is used to formally
model the semantics of an abstraction and to a specific interface.
Role
A role names(indicates) a behavior of an entity participating in a particular context. Or, a role
is the face that an abstraction presents to the world.
For example, consider an instance of the class Person. Depending on the context, that Person
instance may play the role of Mother, PayerOfBills, Employee, Customer, Manager, Pilot,
Singer, and so on. When an object plays a particular role, it presents a face to the world, and
clients that interact with it expect a certain behavior depending on the role that it plays at the
time.
For example, an instance of Person in the role of Manager would present a different set of
properties than if the instance were playing the role of Mother. Figure:3 indicates a role
employee played by person and is represented statically there.
Figure: 3
In Figure:3 the Person presents the role of Employee to the Company, and in that context,
only the properties specified by Employee are visible and relevant to the Company.
Static and Dynamic modeling in UML
A class diagram that indicates a particular role is useful for modeling the static binding of an
abstraction to its interface. To model the dynamic binding of an abstraction to its interface by using
the become stereotype in an interaction diagram, showing an object changing from one role to
another.
Specify the different possible types of that object by rendering each type as a class stereotyped as
type (if the abstraction requires structure and behavior) or as interface (if the abstraction requires
only behavior).
Model all the roles the class of the object may take on at any point in time. It can be done in two
ways:
First, in a class diagram, explicitly type each role that the class plays in its association with other
classes. Doing this specifies the face instances of that class put on in the context of the associated
object.
Second, also in a class diagram, specify the class-to-type relationships using generalization
In an interaction diagram, properly render each instance of the dynamically typed class. Display the
role of the instance in brackets below the object’s name.
To show the change in role of an object, render the object once for each role it plays in the
interaction, and connect these objects with a message stereotyped as become.
Figure:4 shows statically that instances of the Person class may be any of the three types namely,
Candidate, Employee, or Retiree.
Figure:5 Dynamic-modeling
Figure:5 shows the dynamic nature of a person’s type. In this fragment of an interaction diagram, p
(the Person object) changes its role from Candidate to Employee.
Explain common modeling techniques of class.
To model the semantics of a class:
Specify the responsibilities of the class in a note and attach it to the class with a
dependency relationship.
Specify the semantics of a class as a whole in a note stereotyped with ―semantics‖.
Specify the body of a method using structured text or a programming language in a
note and attach it to the class or operation using a dependency relationship.
Specify the pre-conditions and post-conditions for operations using structured text in
a note.
Specify a state machine for a class which represents different states the object
undergoes.
Specify a collaboration that represents a class.
Symbol
Symbol Image Description
Name
These symbols can be used in a variety of ways to represent different iterations of packages,
dependencies, and other elements within a system. Here are the basic components you‘ll find
within a package diagram:
Package: A namespace used to group together logically related elements within a system.
Each element contained within the package should be a packageable element and have a
unique name.
Packageable element: A named element, possibly owned directly by a package. These can
include events, components, use cases, and packages themselves. Packageable elements
can also be rendered as a rectangle within a package, labeled with the appropriate name.
Dependencies: A visual representation of how one element (or set of elements) depends on
or influences another. Dependencies are divided into two groups: access and import
dependencies. (See next section for more info.)
Package merge: A directed relationship in which the contents of one package are extended
by the contents of another. Essentially, the content of two packages are combined to
produce a new package.