Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INTRODUCTION
The UML is a graphical language for visualizing, specifying, constructing, and
documenting the artifacts of a software-intensive system. The UML gives you a standard way
to write a system's blueprints, covering conceptual things, such as business processes and
system functions, as well as concrete things, such as classes written in a specific
programming language, database schemas, and reusable software components.
Model
A model is a simplification of reality. A model provides the blueprints of a system. A
model may be structural, emphasizing the organization of the system, or it may be
behavioral, emphasizing the dynamics of the system.
Why do we model
We build models so that we can better understand the system we are developing.
Through modeling, we achieve four aims.
1. Models help us to visualize a system as it is or as we want it to be.
2. Models permit us to specify the structure or behavior of a system.
3. Models give us a template that guides us in constructing a system.
4. Models document the decisions we have made.
We build models of complex systems because we cannot comprehend such a system in its
entirety.
Principles of Modeling
There are four basic principles of model
1. The choice of what models to create has a profound influence on how a problem is
attacked and how a solution is shaped.
2. Every model may be expressed at different levels of precision.
3. The best models are connected to reality.
4. No single model is sufficient. Every nontrivial system is best approached through a
small set of nearly independent models.
Algorithmic Perspective
0
The traditional view of software development takes an algorithmic perspective.
1
In this approach, the main building block of all software is the procedure or function.
2
This view leads developers to focus on issues of control and the decomposition of
larger algorithms into smaller ones.
3
As requirements change and the system grows, systems built with an algorithmic
focus turn out to be very hard to maintain.
Object-oriented perspective
0
The contemporary view of software development takes an object-oriented
perspective.
1
In this approach, the main building block of all software systems is the object or
class.
2
A class is a description of a set of common objects.
3
Every object has identity, state, and behavior.
4
Object-oriented development provides the conceptual foundation for assembling
systems out of components using technology such as Java Beans or COM+.
An Overview of UML
To understand the UML, you need to form a conceptual model of the language, and this
requires learning three major elements:
1. Things
2. Relationships
3. Diagrams
Things in the UML
There are four kinds of things in the UML:
0 Structural things
1 Behavioral things
2 Grouping things
Annotational things
Structural things are the nouns of UML models. These are the mostly static parts of a
model, representing elements that are either conceptual or physical. In all, there are seven
kinds of structural things.
1. Classes
2. Interfaces
3. Collaborations
4. Use cases
5. Active classes
6. Components
7. Nodes
Class is a description of a set of objects that share the same attributes, operations,
relationships, and semantics. A class implements one or more interfaces. Graphically, a class
is rendered as a rectangle, usually including its name, attributes, and operations.
Interface
0
1
2
An interface is rendered as a circle together with its name. An interface rarely stands alone.
Rather, it is typically attached to the class or component that realizes the interface
Collaboration defines an interaction and is a society of roles and other elements that work
together to provide some cooperative behavior that's bigger than the sum of all the elements.
Therefore, collaborations have structural, as well as behavioral, dimensions. A given class
might participate in several collaborations.
Graphically, a collaboration is rendered as an ellipse with dashed lines, usually including
only its name
Usecase
Use case is a description of set of sequence of actions that a system performs that
yields an observable result of value to a particular actor
Use case is used to structure the behavioral things in a model.
A use case is realized by a collaboration. Graphically, a use case is rendered as an
ellipse with solid lines, usually including only its name
Active class is just like a class except that its objects represent elements whose behavior is
concurrent with other elements. Graphically, an active class is rendered just like a class, but
with heavy lines, usually including its name, attributes, and operations
Component is a physical and replaceable part of a system that conforms to and provides the
realization of a set of interfaces. Graphically, a component is rendered as a rectangle with
tabs
Node is a physical element that exists at run time and represents a computational resource,
generally having at least some memory and, often, processing capability. Graphically, a node
is rendered as a cube, usually including only its name
Behavioral Things are the dynamic parts of UML models. These are the verbs of a model,
representing behavior over time and space. In all, there are two primary kinds of behavioral
things
0 Interaction
1
state machine
2
Interaction
0 Interaction is a behavior that comprises a set of messages exchanged among a set of
objects within a particular context to accomplish a specific purpose
1 An interaction involves a number of other elements, including messages, action
sequences and links
State Machine
0
1
2
Grouping Things:1. are the organizational parts of UML models. These are the boxes into which a model
can be decomposed
2. There is one primary kind of grouping thing, namely, packages.
Package:
Annotational things are the explanatory parts of UML models. These are the comments you
may apply to describe about any element in a model.
0
1
0
Dependency is a semantic relationship between two things in which a change to one
thing may affect the semantics of the other thing
1
Graphically a dependency is rendered as a dashed line, possibly directed, and
occasionally including a label
Association
It is a structural relationship that describes a set of links, a link being a connection
among objects.
Graphically an association is rendered as a solid line, possibly directed, occasionally
including a label, and often containing other adornments, such as multiplicity and role names
Aggregation
It is a special kind of association, representing a structural relationship between a
whole and its parts. Graphically, a generalization relationship is rendered as a solid line with
a hollow arrowhead pointing to the parent
Realization
A class diagram shows a set of classes, interfaces, and collaborations and their
relationships.
Class diagrams that include active classes address the static process view of a system.
2
Object diagram
Object diagrams represent static snapshots of instances of the things found in class
diagrams
These diagrams address the static design view or static process view of a system
An object diagram shows a set of objects and their relationships
A use case diagram shows a set of use cases and actors and their relationships
Use case diagrams address the static use case view of a system.
These diagrams are especially important in organizing and modeling the behaviors of
a system.
Interaction Diagrams
0
Activity diagram
0
An activity diagram is a special kind of a statechart diagram that shows the flow from
activity to activity within a system
1 Activity diagrams address the dynamic view of a system
2
They are especially important in modeling the function of a system and emphasize the
flow of control among objects
3
Component diagram
Deployment diagram
A deployment diagram shows the configuration of run-time processing nodes and the
components that live on them
Deployment diagrams address the static deployment view of an architecture
10
operations. Many of these details can be rendered as graphical or textual adornments to the
class's basic rectangular notation.
Extensibility Mechanisms
The UML's extensibility mechanisms include
1. Stereotypes
2. Tagged values
3. Constraints
Stereotype
Stereotype extends the vocabulary of the UML, allowing you to create new kinds of
building blocks that are derived from existing ones but that are specific to your problem
A tagged value extends the properties of a UML building block, allowing you to create
new information in that element's specification
A constraint extends the semantics of a UML building block, allowing you to add new
rules or modify existing ones
Architecture
0 A system's architecture is perhaps the most important artifact that can be used to
manage these different viewpoints and so control the iterative and incremental
development of a system throughout its life cycle.
1 Architecture is the set of significant decisions about
0
1
2
3
4
11
Software architecture is not only concerned with structure and behavior, but also with usage,
functionality, performance, resilience, reuse, comprehensibility, economic and technology
constraints and trade-offs, and aesthetic concerns.
The design view of a system encompasses the classes, interfaces, and collaborations that
form the vocabulary of the problem and its solution.
This view primarily supports the functional requirements of the system, meaning the
services that the system should provide to its end users.
Process View
The process view of a system encompasses the threads and processes that form the
system's concurrency and synchronization mechanisms.
This view primarily addresses the performance, scalability, and throughput of the system
Implementation View
12
The implementation view of a system encompasses the components and files that
are used to assemble and release the physical system.
0
1
2
This view primarily addresses the configuration management of the system's
releases, made up of somewhat independent components and files that can be assembled in
various ways to produce a running system.
3
Deployment Diagram
0
1
2
The deployment view of a system encompasses the nodes that form the system's
hardware topology on which the system executes.
This view primarily addresses the distribution, delivery, and installation of the parts that
make up the physical system.
13
EXPERIMENT NO-2
AIM: Use case Diagram for Librarian Scenario.
DESCRIPTION:
An Online Public Access Catalog (OPAC) is e-Library website which is part of
Integrated Library System (ILS), also known as a Library Management System (LMS),
and managed by a library or group of libraries.
Patrons of the library can search library catalog online to locate various
resources - books, periodicals, audio and visual materials, or other items under control
of the library.
Patrons may reserve or renew item, provide feedback, and manage their account.
DIAGRAM:
14
EXPERIMENT NO-3
2. Using UML design Abstract factory design pattern.
DESCRIPTION:
It Provide an interface for creating families of related or dependent objects
without specifying their concrete classes
It is also known as KIT
APPLICABILITY:
Use the Abstract Factory pattern when
A system should be independent of how its products are created, composed, and
represented.
A system should be configured with one of multiple families of products.
A family of related product objects is designed to be used together, and you need to
enforce this constraint.
you want to provide a class library of products, and you want to reveal just their
interfaces, not their implementations
DIAGRAM:
15
EXPERIMENT NO-4
AIM: Using UML design Adapter-class Design pattern.
DESCRIPTION:
Convert the interface of a class into another interface clients expect. Adapter lets
classes work together that couldn't otherwise because of incompatible interfaces
APPLICABILITY:
Use the Adapter pattern when
You want to use an existing class, and its interface does not match the one you need.
You want to create a reusable class that cooperates with unrelated or unforeseen
classes, that is, classes that don't necessarily have compatible interfaces.
You need to use several existing subclasses, but it's impractical to adapt their interface
by sub classing every one. An object adapter can adapt the interface of its parent class
DIAGRAM:
16
EXPERIMENT NO-5
AIM: Using UML design Adapter-object Design pattern.
DESCRIPTION:
An object adapter:
Lets a single Adapter work with many Adapteesthat is, the Adaptee itself and all of
its subclasses (if any). The Adapter can also add functionality to all Adaptees at once.
Makes it harder to override Adaptee behavior. It will require subclassing Adaptee and
making Adapter refer to the subclass rather than the Adaptee itself.
Here are other issues to consider when using the Adapter pattern:
Pluggable adapters.
DIAGRAM:
17
EXPERIMENT NO-6
AIM: Using UML design Strategy Design pattern.
DESCRIPTION:
Define a family of algorithms, encapsulate each one, and make them interchangeable.
Strategy lets the algorithm vary independently from clients that use it.
Clients that need line breaking get more complex if they include the line breaking code.
That makes clients bigger and harder to maintain, especially if they support multiple line
breaking algorithms
Different algorithms will be appropriate at different times. We dont want to support
multiple line breaking algorithms if we dont use them all.
l Its difficult to add new algorithms and vary existing ones when line breaking is an
integral part of a client.
DIAGRAM:
18
EXPERIMENT NO-7
AIM: Using UML design Builder Design pattern.
DESCRIPTION:
Separate the construction of a complex object from its representation so that the
same construction process can create different representations.
APPLICABILITY:
Use the Builder pattern when
The algorithm for creating a complex object should be independent of the parts that
make up the object and how they're assembled.
The construction process must allow different representations for the object that's
constructed.
DIAGRAM:
19
EXPERIMENT NO-8
AIM: Using UML design Bridge Design pattern.
DESCRIPTION:
Decouple an abstraction from its implementation so that the two can vary
independently.
It is also known as Handle/Body
Applicability:
Use the Bridge pattern when
(C++) you want to hide the implementation of an abstraction completely from clients.
In C++ the
20
EXPERIMENT NO-9
AIM: Using UML design Decorator Design pattern.
DESCRIPTION:
Attach additional responsibilities to an object dynamically. Decorators provide a
flexible alternative to sub classing for extending functionality.
It is also known as wrapper
Sometimes we want to add responsibilities to individual objects, not to an entire class.
A graphical user interface toolkit, for example, should let you add properties like borders or
behaviors like scrolling to any user interface component.
One way to add responsibilities is with inheritance. Inheriting a border from another
class puts a border around every subclass instance. This is inflexible, however, because the
choice of border is made statically. A client can't control how and when to decorate the
component with a border.
A more flexible approach is to enclose the component in another object that adds the
border. The enclosing object is called a decorator. The decorator conforms to the interface of
the component it decorates so that its presence is transparent to the component's clients. The
decorator forwards requests to the component and may perform
Additional actions (such as drawing a border) before or after forwarding. Transparency lets
you nest decorators recursively, thereby allowing an unlimited number of added
responsibilities.
DIAGRAM:
21
EXPERIMENT NO-10
AIM: Design to represent this chain of responsibility Design pattern.
DESCRIPTION:
Avoid coupling the sender of a request to its receiver by giving more than one object a
chance to handle the request. Chain the receiving objects and pass the request along the chain
until an object handles it.
Applicability:
Use Chain of Responsibility when more than one object may handle a request, and the
handler isn't known a priori. The handler should be ascertained automatically.
You want to issue a request to one of several objects without specifying the receiver
explicitly.
The set of objects that can handle a request should be specified dynamically.
Participants
Handler (Help Handler)
22
if the ConcreteHandler can handle the request, it does so; otherwise it forwards the
request to its successor.
Client
Initiates the request to a ConcreteHandler object on the chain.
DIAGRAM:
23
EXPERIMENT NO-11
AIM: Design a Flyweight Design pattern.
DESCRIPTION:
Use sharing to support large numbers of fine-grained objects efficiently
A flyweight is a shared object that can be used in multiple contexts simultaneously.
The flyweight acts as an independent object in each contextit's indistinguishable from an
instance of the object that's not shared. Flyweights cannot make assumptions about the
context in which they operate. The key concept here is the distinction between intrinsic and
extrinsic state. Intrinsic state is stored in the flyweight; it consists of information that's
independent of the flyweight's context, thereby making it sharable. Extrinsic state depends on
and varies with the flyweight's context and therefore can't be shared. Client objects are
responsible for passing extrinsic state to the flyweight when it needs it.
Flyweights model concepts or entities that are normally too plentiful to represent with
objects. For example, a document editor can create a flyweight for each letter of the alphabet.
Each flyweight stores a character code, but its coordinate position in the document and its
typographic style can be determined from the text layout algorithms and formatting
commands in effect wherever the character appears. The character code is intrinsic state,
while the other information is extrinsic.
Applicability:
24
The Flyweight pattern's effectiveness depends heavily on how and where it's used.
Apply the Flyweight pattern when all of the following are true:
An application uses a large number of objects. Storage costs are high because of the
sheer quantity of objects.
Many groups of objects may be replaced by relatively few shared objects once
extrinsic state is removed.
The application doesn't depend on object identity. Since flyweight objects may be
shared, identity tests will return true for conceptually distinct objects
DIAGRAM:
25
EXPERIMENT NO-12
AIM: Using UML design Facade Design pattern.
26
DESCRIPTION:
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a
higher-level interface that makes the subsystem easier to use.
Use the Facade pattern when
you want to provide a simple interface to a complex subsystem. Subsystems often get
more complex as they evolve. Most patterns, when applied, result in more and smaller
classes. This makes the subsystem more reusable and easier to customize, but it also becomes
harder to use for clients that don't need to customize it. A facade can provide a simple default
view of the subsystem that is good enough for most clients. Only clients needing more
customizability will need to look beyond the facade.
There are many dependencies between clients and the implementation classes of an
abstraction. Introduce a facade to decouple the subsystem from clients and other subsystems,
thereby promoting subsystem independence and portability.
You want to layer your subsystems. Use a facade to define an entry point to each
subsystem level. If subsystems are dependent, then you can simplify the dependencies
between them by making them
Communicate with each other solely through their facades.
DIAGRAM:
EXPERIMENT NO-13
AIM: Using UML design Iterator Design pattern.
27
DESCRIPTION:
Provide a way to access the elements of an aggregate object sequentially without
exposing its underlying representation.
to provide a uniform interface for traversing different aggregate structures (that is, to
support polymorphic iteration).
DIAGRAM:
EXPERIMENT NO-14
AIM: Using UML design Mediator Design pattern.
28
DESCRIPTION:
Define an object that encapsulates how a set of objects interact. Mediator promotes loose
coupling by keeping objects from referring to each other explicitly, and it lets you vary their
interaction independently.
Use the Mediator pattern when
Reusing an object is difficult because it refers to and communicates with many other
objects.
a behavior that's distributed between several classes should be customizable without a lot
of sub classing
DIAGRAM:
EXPERIMENT NO-15
14. Using UML design Proxy Design pattern.
29
DESCRIPTION:
Provide a surrogate or placeholder for another object to control access to it.
It is also known as Surrogate
Participants:
Proxy (ImageProxy)
Maintains a reference that lets the proxy access the real subject. Proxy may refer to a
Subject If the Real Subject and Subject interfaces are the same.
provides an interface identical to Subject's so that a proxy can by substituted for the real
Subject.
Controls access to the real subject and may be responsible for creating and deleting it.
Remote proxies are responsible for encoding a request and its arguments and for
Sending the encoded request to the real subject in a different address space.
virtual proxies may cache additional information about the real subject so that they
can postpone accessing it. For example, the Image Proxy from the Motivation caches the
real image's extent.
Protection proxies check that the caller has the access permissions required to
perform
a request.
Subject (Graphic)
Defines the common interface for RealSubject and Proxy so that a Proxy can be used
Anywhere a RealSubject is expected.
RealSubject (Image)
Defines the real object that the proxy represents.
DIAGRAM:
30
EXPERIMENT NO-16
31
An object structure contains many classes of objects with differing interfaces, and you
want to perform operations on these objects that depend on their concrete classes.
Many distinct and unrelated operations need to be performed on objects in an object
structure, and you want to avoid "polluting" their classes with these operations. Visitor lets
you keep related operations together by defining them in one class. When the object structure
is shared by many applications, use Visitor to put operations in just those applications that
need them.
The classes defining the object structure rarely change, but you often want to define
new operations over the structure. Changing the object structure classes requires redefining
the interface to all visitors, which is potentially costly. If the object structure classes change
often, then it's probably better to define the operations in those classes
Diagram:
32