Unit 3 Se
Unit 3 Se
Class Diagrams - Interaction Diagrams - State chart Diagrams – Activity Diagrams - Package
Diagrams - Component Diagrams - Deployment Diagrams - Diagram Organization- Diagram
Extensions. Design Process- Design concepts: Abstraction, Architecture, patterns, Separation
of Concerns, Modularity, Information Hiding, Functional Independence, Refinement, Aspects,
Refactoring, Object Oriented Design Concepts, Design Classes- Design Model: Data,
Architectural, Interface, Component, Deployment Level Design Elements.
Introduction to UML
UML defines various kinds of diagrams to cover most of the aspects of a system. You can also
create your own set of diagrams to meet your requirements. Diagrams are generally made in
an incremental and iterative way. There are two broad categories of diagrams and they are
again divided into subcategories –
• Structural diagrams: The structural diagrams represent the static aspect of the
system. These static aspects represent those parts of a diagram, which forms the main
structure and are therefore stable. These static parts are represented by classes,
interfaces, objects, components, and nodes. It includes class diagrams, deployment
diagram and package diagrams, etc.
Example 2 :
Class diagram
The class diagram is a static diagram.A class diagram describes the structure of a system in
terms of the classes that exist within the system by characterizing the objects in the system,
the relationship between the objects, and the attributes and operations for each class of objects.
Class diagram provide a graphical notation for modeling classes and their relationship.They are
concise, easy to understand, and work well in practice.
The main elements of a class diagram are boxes, which are the icons used to represent classes
and interfaces. Each box is divided into horizontal parts. The top part contains the name of the
class. The middle section lists the attributes of the class. An attribute refers to something that
an object of that class knows or can provide all the time. Attributes are usually implemented as
fields of the class. The third part represents operations. An operation refers to what objects of
the class can do. It is usually implemented as a method of the class. Each attribute can have a
name, a type, and a level of visibility. The type and visibility are optional. The type follows the
name and is separated from the name by a colon. The visibility is indicated by a preceding –,
#, ~, or +, indicating private, protected, package, or public respectively.
Example for class:
Class diagrams also provide provisions for representing other forms of relations like
inheritance, dependencies, aggregation and composition. Some of the relationships which can
be represented in a class diagram are:
Sr. Name Symbol Meaning
No.
1 Association An association represents
the relationship that exist
between various classes
An abstract class or abstract method is indicated by the use of italics for the name in the class
diagram. A class that is a subclass of another class is connected to it by an arrow with a solid
line for its shaft and with a triangular hollow arrowhead. The arrow points from the subclass to
the superclass. In UML, such a relationship is called a generalization. An interface is
indicated by adding the phrase ―«interface»‖ (called a stereotype) above the name. An
interface can also be represented graphically by a hollow circle.
An association between two classes means that there is a structural relationship between them.
Associations are represented by solid lines. An association has many optional parts. It can be
labeled, as can each of its ends, to indicate the role of each class in the association. A
dependency relationship represents another connection between classes and is indicated by a
dashed line (with optional arrows at the ends and with optional labels). One class depends on
another if changes to the second class might require changes to the first class The multiplicity
of one end of an association means the number of objects of that class associated with the other
class. A multiplicity is specified by a nonnegative integer or by a range of integers. A
multiplicity specified by ―0..1 means that there are 0 or 1 objects on that end of the association.
An aggregation is a special kind of association indicated by a hollow diamond on one end of
the icon. It indicates a ―whole/part relationship, in that the class to which the arrow points is
considered a ―part of the class at the diamond end of the association. A composition is an
aggregation indicating strong ownership of the parts. Another common element of a class
diagram is a note, which is represented by a box with a dog-eared corner and is connected to
other icons by a dashed line. It can have arbitrary content (text and graphics) and is similar to
comments in programming languages.
Example,
Interaction diagrams
The interaction diagram is used to describe some type of interactions among the different
elements in the model. This interaction is a part of dynamic behaviour of the system. The
purpose of interaction diagram is to
• describe the message flow in the system
• describe structural organization of the objects
• describe interaction among objects
• capture the dynamic behaviour of a system.
Interaction diagrams can be used
• to model the flow of control by time sequence
• to model the flow of control by structural organizations.
The following things are to be identified clearly before drawing the interaction diagram:
• Objects taking part in the interaction
• Message flows among the objects.
• The sequence in which the messages are flowing
• Object organization.
The interactive behavior is represented in UML by four diagrams. They are:
1. Sequence diagram
UML sequence diagrams are interaction diagrams that capture the interaction between
objects in a sequential order i.e., the order in which these interactions take place.
Sequence diagram emphasizes on time sequence of messages. It is used to capture the
order of messages flowing from one object to another. Message flow means the
sequence of control flow from one object to another. These diagrams are useful to
represent the details of a UML use case. Sequence diagrams are sometimes known as
event diagrams or event scenarios. The sequence diagram does not describe the object
organization. If the time sequence is important, then the sequence diagram is used.
There are many other special features that can be included in a sequence diagram.
1. You can distinguish between synchronous and asynchronous messages.
Synchronous messages are shown with solid arrowheads while asynchronous messages
are shown with stick arrowheads.
2. You can show an object sending itself a message with an arrow going out from the
object, turning downward, and then pointing back to the same object.
3. You can show object creation by drawing an arrow appropriately labeled (for
example, with a «create» label) to an object’s box. In this case, the box will appear
lower in the diagram than the boxes corresponding to objects already in existence when
the action begins.
4. You can show object destruction by a big X at the end of the object’s lifeline. Other
objects can destroy an object, in which case an arrow points from the other object to
the X. An X is also useful for indicating that an object is no longer usable and so is
ready for garbage collection.
Sequence diagram notations:
1. Lifelines represent an individual participant within an interaction. Lifelines are
represented by vertical dashed lines, connecting at
the top to an object or actor
2. Actors represent the user, external hardware or other subject setting off a particular
sequence. They often appear as a stick figure icon and are placed to the left of the first
object on the horizonal axis.
3. Activation bars/ Activation box -- sometimes called focus of control -- are thin
rectangular boxes that sit vertically on top of an object's lifeline to indicate the
duration of a particular operation.
Bank server
3. Timing diagram
In UML, the timing diagrams are a part of Interaction diagrams that do not incorporate
similar notations as that of sequence and collaboration diagram. It consists of a graph
or waveform that depicts the state of a lifeline at a specific point of time. It illustrates
how conditions are altered both inside and between lifelines alongside linear time axis.
The timing diagram describes how an object underwent a change from one form to
another. A waveform portrays the flow among the software programs at several
instances of time.
Activity diagram
An activity diagram is a type of flow chart with additional support for parallel behavior. This
diagram explains overall flow of control. Activity diagram is another important diagram in
UML to describe dynamic aspects of the system. Activity diagram represents the flow from
one activity to another activity. It is similar to a flowchart except that an activity diagram can
show concurrent flows.The activity can be described as an operation of the system. The control
flow is drawn from one operation to another. This flow can be sequential, branched or
concurrent. This distinction is important for a distributed system. Activity diagrams deals with
all type of flow control by using different elements like fork, join etc.
Activity diagram notations:
No. Name Symbol Description
1. Activity / The main component of an activity
Action node Activity diagram is an action node, represented
by a rounded rectangle,Represent
individual activity of system.
2. Transition Represents flow of data from one
activity to
another.
3. Decision Decision node is a control node that accepts
tokens on one or more incoming edges and
selects outgoing edge from two or more
outgoing flows. The notation for a decision
node is a diamond-shaped symbol.
4. Initial activity Initial node is a control node at which flow
starts when the activity is invoked. Activity
may have more than one initial node. Initial
nodes are shown as a small solid circle.
5. Final activity Final node is a control final node that stops
all flows in an activity. Activity final nodes
are shown as a solid circle with a hollow
circle inside.
Example:
Package diagram
Package diagrams are structural diagrams used to show the organization and arrangement of
various model elements in the form of packages. A package is a grouping of related UML
elements, such as diagrams, documents, classes, or even other packages. Each element is nested
within the package, which is depicted as a file folder within the diagram, then arranged
hierarchically within the diagram. Package diagrams are most commonly used to provide a
visual organization of the layered architecture within any UML classifier, such as a software
system. A well-designed package diagram provides numerous benefits to those looking to
create a visualization of their UML system or project.
They provide a clear view of the hierarchical structure of the various UML elements within a
given system. These diagrams can simplify complex class diagrams into well-ordered visuals.
Each diagram includes the following :
• Packages appear as rectangles with small tabs at the top.
• The package name is on the tab or inside the rectangle.
• The dotted arrows are dependencies.
• One package depends on another if changes in the other could possibly force changes
in the first.
A package in the Unified Modelling Language helps:
• To group elements
• To provide a namespace for the grouped elements
• A package may contain other packages, thus providing for a hierarchical organization
of packages.
Packages can be represented by the notations as shown below:
There are two sub-types involved in dependency. They are <<import>> & <<access>>.
<<import>>- one package imports the functionality of other package.
Deployment diagram
It is a type of structural diagram. The deployment diagram visualizes the physical hardware on
which the software will be deployed. It portrays the static deployment view of a system. It
involves the nodes and their relationships.
The main purpose of the deployment diagram is to represent how software is installed on the
hardware component. It depicts in what manner a software interacts with hardware to perform
its execution.
The deployment diagram does not focus on the logical components of the system, but it put its
attention on the hardware topology.
The following figure shows the deployment diagram for a package. In such a diagram,
hardware components are drawn in boxes labeled with “«device»”. Communication paths
between hardware components are drawn with lines with optional labels. The paths are
labeled with the communication protocol and the type of network used to connect the devices.
Each node in a deployment diagram can also be annotated with details about the device. For
example, in the Figure the browser client is depicted to show that it contains an artifact
consisting of the Web browser software.
An artifact is typically a file containing software running on a device. You can also specify
tagged values, as is shown in Figure in the Web server node. These values define the vendor
of the Web server and the operating system used by the server. Deployment diagrams can also
display execution environment nodes, which are drawn as boxes containing the label
“«execution environment»”. These nodes represent systems, such as operating systems, that
can host other software.
Diagram organization
Models of complex systems quickly become complex as developers refine them. UML model
management provides a mechanism for diagram organization to deal with the complexity of
the models. They are:
1. Packages
• It is a mechanism for grouping of logically related UML elements.
• A package is a piece of model. Every part of a model must belong to one
package.
• UML does not impose a rule for composing packages, but a good decomposition
into packages will greatly enhance model maintainability.
• Packages contain top level model elements such as classes and their
relationships, state machines, use case graphs, interactions, and collaborations
• Packages may contain other packages.
• Packages are general purpose hierarchial organizational units of UML models
• They can be used for storage, access control,configuration management etc.
• A package is shown as a large rectangle with a small rectangle attached on one
corner
2. Dependencies on packages
• Dependencies arise among individual elements.
• Dependencies among packages summarize dependencies among elments in
them.
• Packages are drawn as rectangles with tabs on them. Dependencies are shown
as dashed arrows.
• A package cannot access the contents of another package. Packages are opaque
unless they are opened by an access or import dependency.
• The access dependency applies directly to packages and other containers.
• The import dependency is used to add names to the namespace of the client
package as aliases for the full pathnames.
Diagram extensions
The extensibility mechanisms allow you to customize and extend the UML by adding new
building blocks, creating new properties and specifying new semantics in order to make the
language suitable for your specific problem domain. There are three extensibility mechanisms
that are defined by the UML:
1. Constraints
A constraint is a semantic restriction represented as a text expression. Constraints
specify semantics and/or conditions that must be held true at all times for the elements
of a model. Constraints can express restrictions and relationships that cannot be
expressed using UML notations. These are shown as the expression strings enclosed in
braces.
2. Tagged value
Tagged values or meta attributes are used to extend the properties of UML building
block so that you can add additional information in the specification of a model element.
Tagged values are shown in the form: tag=value where tag is the tag name and value
is a literal value.
3. Stereotypes
A stereotype is based on an existing element. The information content of the
stereotyped element is same as the existing model element. This permits a tool to store
and manipulate the new element the same way it does the existing element.
A stereotype is rended as a name enclosed by guillemets (<< >>) and placed above the
name of another element.
SOFTWARE DESIGN
Software design encompasses the set of principles, concepts, and practices that lead to the
development of a high-quality system or product. Design is pivotal to successful software
engineering. Design allows you to model the system or product that is to be built. This model
can be assessed for quality and improved before code is generated, tests are conducted, and end
users become involved in large numbers. Design is the place where software quality is
established. A design model that encompasses architectural, interface, component level, and
deployment representations is the primary work product that is produced during software
design. Beginning once software requirements have been analyzed and modeled, software
design is the last software engineering action within the modeling activity and sets the stage
for construction (code generation and testing).
The requirements model, manifested by scenario-based, class-based, flow-oriented, and
behavioral elements, feed the design task. Design produces a data/class design, an architectural
design, an interface design, and a component design. The data / class design transforms class
models into design class realizations and the requisite data structures required to implement
the software. The objects and relationships defined in the CRC diagram.
The architectural design defines the relationship between major structural elements of the
software, the architectural styles and design patterns that can be used to achieve the
requirements defined for the system, and the constraints that affect the way in which
architecture can be implemented.
The interface design describes how the software communicates with systems that interoperate
with it, and with humans who use it. An interface implies a flow of information (e.g., data
and/or control) and a specific type of behavior.
The component-level design transforms structural elements of the software architecture into a
procedural description of software components. Information obtained from the class-based
models, flow models, and behavioral models serve as the basis for component design.
The importance of software design can be stated with a single word—quality.
Design process
Software design is an iterative process through which requirements are translated into a
“blueprint” for constructing the software. Initially, the blueprint depicts a holistic view of
software. That is, the design is represented at a high level of abstraction— a level that can be
directly traced to the specific system objective and more detailed data, functional, and
behavioral requirements. As design iterations occur, subsequent refinement leads to design
representations at much lower levels of abstraction.
Software Quality Guidelines and Attributes
Throughout the design process, the quality of the evolving design is assessed with a series of
technical reviews. McGlaughlin [McG91] suggests three characteristics that serve as a guide
for the evaluation of a good design:
• The design must implement all of the explicit requirements contained in the requirements
model, and it must accommodate all of the implicit requirements desired by stakeholders.
• The design must be a readable, understandable guide for those who generate code and for
those who test and subsequently support the software.
• The design should provide a complete picture of the software, addressing the data, functional,
and behavioral domains from an implementation perspective.
Quality Guideline
In order to evaluate the quality of a design representation, the members of the software team
must establish technical criteria for good design. The guidelines are:
1. A design should exhibit an architecture that
(1) has been created using recognizable architectural styles or patterns,
(2) is composed of components that exhibit good design characteristics , and
(3) can be implemented in an evolutionary fashion,2 thereby facilitating implementation
and testing.
2. A design should be modular; that is, the software should be logically partitioned into
elements or subsystems.
3. A design should contain distinct representations of data, architecture, interfaces, and
components
4. A design should lead to data structures that are appropriate for the classes to be implemented
and are drawn from recognizable data patterns.
5. A design should lead to components that exhibit independent functional characteristics.
6. A design should lead to interfaces that reduce the complexity of connections between
components and with the external environment.
7. A design should be derived using a repeatable method that is driven by information obtained
during software requirements analysis.
8. A design should be represented using a notation that effectively communicates its meaning
Quality Attributes.
Hewlett-Packard [Gra87] developed a set of software quality attributes that has been given the
acronym FURPS—functionality, usability, reliability, performance, and supportability. The
FURPS quality attributes represent a target for all software design:
• Functionality is assessed by evaluating the feature set and capabilities of the program, the
generality of the functions that are delivered, and the security of the overall system
• Usability is assessed by considering human factors, overall aesthetics, consistency, and
documentation.
• Reliability is evaluated by measuring the frequency and severity of failure, the accuracy of
output results, the mean-time-to-failure (MTTF), the ability to recover from failure, and the
predictability of the program.
• Performance is measured by considering processing speed, response time, resource
consumption, throughput, and efficiency.
• Supportability combines the ability to extend the program (extensibility), adaptability,
serviceability—these three attributes represent a more common term, maintainability—and in
addition, testability, compatibility, configurability (the ability to organize and control elements
of the software configuration), the ease with which a system can be installed, and the ease with
which problems can be localized.
Design concepts
The software design concepts that span both traditional and object-oriented software
development are:
Abstraction
When you consider a modular solution to any problem, many levels of abstraction can be posed.
At the highest level of abstraction, a solution is stated in broad terms using the language of the
problem environment. At lower levels of abstraction, a more detailed description of the solution
is provided.
Refinement
Stepwise refinement is a top-down design strategy originally proposed by Niklaus Wirth
[Wir71]. A program is developed by successively refining levels of procedural detail. A
hierarchy is developed by decomposing a macroscopic statement of function (a procedural
abstraction) in a stepwise fashion until programming language statements are reached.
Refinement is actually a process of elaboration. You begin with a statement of function (or
description of information) that is defined at a high level of abstraction. That is, the statement
describes function or information conceptually but provides no information about the internal
workings of the function or the internal structure of the information. You then elaborate on the
original statement, providing more and more detail as each successive refinement (elaboration)
occurs. Abstraction and refinement are complementary concepts. Abstraction enables you to
specify procedure and data internally but suppress the need for “outsiders” to have knowledge
of low-level details. Refinement helps you to reveal low-level details as design progresses.
Both concepts allow you to create a complete design model as the design evolves.
Aspects
An aspect is a representation of a crosscutting concern. It is important to identify aspects so
that the design can properly accommodate them as refinement and modularization occur. In an
ideal context, an aspect is implemented as a separate module (component) rather than as
software fragments that are “scattered” or “tangled” throughout many components. To
accomplish this, the design architecture should support a mechanism for defining an aspect—
a module that enables the concern to be implemented across all other concerns that it crosscuts.
Refactoring
Refactoring is a reorganization technique that simplifies the design (or code) of a component
without changing its function or behavior. When software is refactored, the existing design is
examined for redundancy, unused design elements, inefficient or unnecessary algorithms,
poorly constructed or inappropriate data structures, or any other design failure that can be
corrected to yield a better design. For example, a first design iteration might yield a component
that exhibits low cohesion (i.e., it performs three functions that have only limited relationship
to one another). After careful consideration, you may decide that the component should be
refactored into three separate components, each exhibiting high cohesion. The result will be
software that is easier to integrate, easier to test, and easier to maintain.
3. Classes
A class is a generalized description of an object. An object is an instance of a class. A
class defines all the attributes, which an object can have and methods, which represents
the functionality of the object.
4. Messages
Objects communicate by message passing. Messages consist of the integrity of the
target object, the name of the requested operation, and any other action needed to
perform the function. Messages are often implemented as procedure or function calls.
5. Polymorphism
OOD languages provide a mechanism where methods performing similar tasks but
vary in arguments, can be assigned the same name. This is known as polymorphism,
which allows a single interface is performing functions for different types. Depending
upon how the service is invoked, the respective portion of the code gets executed.
6. Abstraction
Abstraction means, showcasing only the required things to the outside world while
hiding the details. The concept of abstraction focuses on what an object does, instated
of how an object is represented or ―how it works.
7. Encapsulation
Encapsulation means that we want to hide unnecessary details from the user.
Design classes
As the design model evolves, you will define a set of design classes that refine the analysis
classes by providing design detail that will enable the classes to be implemented, and
implement a software infrastructure that supports the business solution. Five different types of
design classes, each representing a different layer of the design architecture, can be developed:
• User interface classes define all abstractions that are necessary for human computer
interaction (HCI).
• Business domain classes are often refinements of the analysis classes defined earlier. The
classes identify the attributes and services (methods) that are required to implement some
element of the business domain.
• Process classes implement lower-level business abstractions required to fully manage the
business domain classes.
• Persistent classes represent data stores (e.g., a database) that will persist beyond the
execution of the software.
• System classes implement software management and control functions that enable the system
to operate and communicate within its computing environment and with the outside world.
The four characteristics of a well-formed design class include the following:
• Complete and sufficient : A design class should be the complete encapsulation of all
attributes and methods that can reasonably be expected to exist for the class. The
property sufficiency ensures that the design class contains only those methods that are
sufficient to achieve the intent of the class, no more and no less
• Primitiveness: Methods associated with a design class should be focused on
accomplishing one service for the class. Once the service has been implemented with a
method, the class should not provide another way to accomplish the same thing.
• High cohesion : A cohesive design class has a small, focused set of responsibilities and
single-mindedly applies attributes and methods to implement those responsibilities.
• Low coupling : Within the design model, it is necessary for design classes to
collaborate with one another. However, collaboration should be kept to an acceptable
minimum. If a design model is highly coupled (all design classes collaborate with all
other design classes), the system is difficult to implement, to test, and to maintain over
time.
Design model
The design model can be viewed in two different dimensions as:
• The process dimension indicates the evolution of the design model as design tasks are
executed as part of the software process
• The abstraction dimension represents the level of detail as each element of the analysis
model is transformed into a design equivalent and then refined iteratively.
The elements of the design model use many of the same UML diagrams that were used in
the analysis model.
The design model has four major elements: data, architecture, components, and interface.
1. Data Design Elements
Data design (sometimes referred to as data architecting) creates a model of data and/or
information that is represented at a high level of abstraction (the customer/user’s view
of data). This data model is then refined into progressively more implementation-
specific representations that can be processed by the computer-based system.
2. Architectural Design Elements
Architectural design elements give us an overall view of the software. The architectural
design element is usually depicted as a set of interconnected subsystems, often derived
from analysis packages within the requirements model. Each subsystem may have it’s
own architecture (e.g., a graphical user interface be structured according to a pre
existing architectural style for user interfaces).
3. Interface Design Elements
The interface design elements for software depict information flows into and out of the
system and how it is communicated among the components defined as part of the
architecture. There are three important elements of interface design: (1) the user
interface (UI); (2) external interfaces to other systems, devices, networks, or other
producers or consumers of information; and (3) internal interfaces between various
design components. These interface design elements allow the software to
communicate externally and enable internal communication and collaboration among
the components that populate the software architecture. Usability design (UI design)
incorporates aesthetic elements (e.g., layout, color, graphics, interaction mechanisms),
ergonomic elements (e.g., information layout and placement, metaphors, UI
navigation), and technical elements (e.g., UI patterns, reusable components). In general,
the UI is a unique subsystem within the overall application architecture. The design of
external interfaces should incorporate error checking and (when necessary) appropriate
security features. The design of internal interfaces is closely aligned with component-
level design.
Questions:
• Explain various object-oriented concepts that are needed for conceptual modelling in
UML
• Explain software design concepts
• What is the purpose of class diagram? Explain with example.
• Illustrate deployment diagram with an example
• Explain package diagram with an example
• Explain activity diagram and state diagram
• Differentiate information hiding and functional independence
• Draw a use case diagram for library management system.
• Explain the term modularity
• Explain neatly about different design concepts.