Software Engineering Design-Concepts
Software Engineering Design-Concepts
1
Design
Good software design should exhibit:
Firmness: A program should not have any bugs that
inhibit its function.
Commodity: A program should be suitable for the
purposes for which it was intended.
Delight: The experience of using the program should
be pleasurable one.
2
Design within the context of software
engineering
3
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 and the detailed data content
depicted by class attributes and other notation
provide the basis for the data design action.
Part of class design may occur in conjunction
with the design of software architecture.
More detailed class design occurs as each
software component is designed.
4
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.
7
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.
8
Importance of software quality
Design is the place where quality is fostered in software
engineering.
Design provides you with representations of software that can
be assessed for quality.
Design is the only way that you can accurately translate
stakeholder’s requirements into a finished software product or
system.
Software design serves as the foundation for all the software
engineering and software support activities that follow.
Without design, you risk building an unstable system—
one that will fail when small changes are made;
One that may be difficult to test;
one whose quality cannot be assessed until late in the software
process, when time is short and many dollars have already
been spent.
9
Translating the requirements model
into the design model
10
Design and Quality
Three characteristics that serve as a guide for the
evaluation of a good design:
12
The evolution of software Design
The evolution of software design is a continuing process
that has now spanned almost six decades.
Early design work concentrated on criteria for the
development of modular programs and methods for
refining software structures in a top down manner .
Procedural aspects of design definition evolved into a
philosophy called structured programming .
Later work proposed methods for the translation of data
flow or data structure into a design definition.
Newer design approaches proposed an object-oriented
approach to design derivation.
13
Design Concepts
Abstraction—data, procedure, control
Architecture—the overall structure of the software
Patterns—”conveys the essence” of a proven design solution
Separation of Concerns —any complex problem can be more easily handled if it is
subdivided into pieces
Modularity—compartmentalization of data and function
Hiding—controlled interfaces
Functional independence—single-minded function and low coupling
Refinement—elaboration of detail for all abstractions
Aspects—a mechanism for understanding how global requirements affect
design
Refactoring—a reorganization technique that simplifies the design
OO design concepts
Design Classes—provide design detail that will enable analysis classes to be implemented
14
1.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.
A procedural abstraction refers to a sequence of
instructions that have a specific and limited function.
The name of a procedural abstraction implies these
functions, but specific details are suppressed.
An example of a procedural abstraction would be the word
open for a door. Open implies a long sequence of
procedural steps (e.g., walk to the door, reach out and
grasp knob, turn knob and pull door, step away from
moving door, etc.).
15
Procedural
Abstraction open
details of enter
algorithm
16
A data abstraction is a named collection of data
that describes a data object.
In the context of the procedural abstraction
open, we can define a data abstraction called
door.
Like any data object, the data abstraction for
door would encompass a set of attributes that
describe the door (e.g., door type, swing
direction, opening mechanism, weight,
dimensions).
It follows that the procedural abstraction open
would make use of information contained in the
attributes of the data abstraction door.
17
Data
Abstraction door
manufacturer
model number
type
swing direction
inserts
lights
type
number
weight
opening mechanism
18
2. Architecture
The overall structure of the software and the
ways in which that structure provides conceptual
integrity for a system.
19
Shaw and Garlan describe a set of properties that should be
specified as part of an architectural design:
20
Given the specification of these properties, the architectural
design can be represented using one or more of a number of
different models.
Structural models represent architecture as an organized
collection of program components.
Framework models increase the level of design abstraction by
attempting to identify repeatable architectural design
frameworks that are encountered in similar types of
applications.
Dynamic models address the behavioral aspects of the
program architecture, indicating how the structure or system
configuration may change as a function of external events.
Process models focus on the design of the business or
technical process that the system must accommodate.
Finally, functional models can be used to represent the
functional hierarchy of a system.
21
3. Patterns
Brad Appleton defines a design pattern in the following
manner: “A pattern is a named nugget of insight which
conveys the essence of a proven solution to a recurring
problem within a certain context amidst competing
concerns”
The intent of each design pattern is to provide a
description that enables a designer to determine
(1) whether the pattern is applicable to the current work,
(2) whether the pattern can be reused (hence, saving
design time), and
(3) Whether the pattern can serve as a guide for
developing a similar, but functionally or structurally
different pattern.
22
Design Pattern Template
Pattern name—describes the essence of the pattern in a short but expressive
name
Intent—describes the pattern and what it does
Also-known-as—lists any synonyms for the pattern
Motivation—provides an example of the problem
Applicability—notes specific design situations in which the pattern is
applicable
Structure—describes the classes that are required to implement the pattern
Participants—describes the responsibilities of the classes that are required to
implement the pattern
Collaborations—describes how the participants collaborate to carry out their
responsibilities
Consequences—describes the “design forces” that affect the pattern and the
potential trade-offs that must be considered when the pattern is implemented
Related patterns—cross-references related design patterns
23
4. Separation of Concerns
Any complex problem can be more easily handled if
it is subdivided into pieces that can each be solved
and/or optimized independently
A concern is a feature or behavior that is specified as
part of the requirements model for the software.
By separating concerns into smaller, and therefore
more manageable pieces, a problem takes less effort
and time to solve.
24
For two problems, p1 and p2, if the perceived
complexity of p1 is greater than the perceived
complexity of p2, it follows that the effort required
to solve p1 is greater than the effort required to
solve p2.
As a general case, this result is intuitively obvious.
It does take more time to solve a difficult problem.
It also follows that the perceived complexity of two
problems when they are combined is often greater
than the sum of the perceived complexity when
each is taken separately.
This leads to a divide-and-conquer strategy—it’s
easier to solve a complex problem when you break
it into manageable pieces.
25
Modularity
Software is divided into separately named and addressable components,
sometimes called modules, that are integrated to satisfy problem
requirements.
"modularity is the single attribute of software that allows a program to be
intellectually manageable" .
Monolithic software (i.e., a large program composed of a single module)
cannot be easily grasped by a software engineer.
The number of control paths, span of reference, number of variables, and overall
complexity would make understanding close to impossible.
In almost all instances, you should break the design into many modules,
hoping to make understanding easier and as a consequence, reduce the cost
required to build the software.
26
Modularity and Software Cost
27
the effort (cost) to develop an individual software module does decrease as the
total number of modules increases.
Given the same set of requirements, more modules means smaller individual
size.
However, as the number of modules grows, the effort (cost) associated with
integrating the modules also grows.
These characteristics lead to a total cost or effort curve shown in the figure.
There is a number, M, of modules that would result in minimum development
cost, but we do not have the necessary sophistication to predict M with
assurance.
You modularize a design (and the resulting program) so that
development can be more easily planned;
software increments can be defined and delivered;
changes can be more easily accommodated;
testing and debugging can be conducted more efficiently, and
long-term maintenance can be conducted without serious side effects.
28
Information Hiding
The principle of information hiding suggests that modules be
“characterized by design decisions that (each) hides from all others.”
Because most data and procedural detail are hidden from other parts
of the software, inadvertent errors introduced during modification are
less likely to propagate to other locations within the software.
29
Information Hiding
module • algorithm
controlled
interface • data structure
clients "secret"
30
Functional Independence
Functional independence is achieved by developing modules with
"single-minded" function and an "aversion" to excessive interaction
with other modules.
Software with effective modularity, that is, independent
modules, is easier to develop because function can be
compartmentalized and interfaces are simplified
Independent modules are easier to maintain (and test)
because secondary effects caused by design or code
modification are limited, error propagation is reduced, and
reusable modules are possible.
Functional independence is a key to good design, and
design is the key to software quality.
Independence is assessed using two qualitative criteria:
cohesion and coupling.
31
Cohesion is an indication of the relative functional strength of a module.
A cohesive module performs a single task, requiring little interaction with
other components in other parts of a program. Stated simply, a cohesive
module should (ideally) do just one thing.
32
Refinement
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.
33
Stepwise
open
Refinement
walk to door;
reach for knob;
34
Aspects
Consider two requirements, A and B. Requirement
A crosscuts requirement B “if a software
decomposition [refinement] has been chosen in
which B cannot be satisfied without taking A into
account.
An aspect is a representation of a cross-cutting
concern.
35
Aspects—An Example
Consider two requirements for the SafeHomeAssured.com WebApp.
Requirement A is described via the use-case Access camera surveillance
via the Internet. A design refinement would focus on those modules that
would enable a registered user to access video from cameras placed
throughout a space. Requirement B is a generic security requirement that
states that a registered user must be validated prior to using
SafeHomeAssured.com. This requirement is applicable for all functions
that are available to registered SafeHome users. As design refinement
occurs, A* is a design representation for requirement A and B* is a design
representation for requirement B. Therefore, A* and B* are representations
of concerns, and B* cross-cuts A*.
An aspect is a representation of a cross-cutting concern. Therefore, the
design representation, B*, of the requirement, a registered user must be
validated prior to using SafeHomeAssured.com, is an aspect of the
SafeHome WebApp.
36
Refactoring
37
OO Design Concepts
Design classes
Inheritance—all responsibilities of a superclass is
immediately inherited by all subclasses
Messages—stimulate some behavior to occur in the
receiving object
Polymorphism—a characteristic that greatly reduces
the effort required to extend the design
38
Design Classes
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.
39
Arlow and Neustadt suggest that each design class be
reviewed to ensure that it is “well-formed.”
They define four characteristics of a well-formed design
class:
Complete and sufficient: A design class should be the
complete encapsulation of all attributes and methods that
can reasonably be expected.
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.
40
Low coupling:
41
Design class for Floor plan and composite
aggregation for the class
42
Dimensions of the Design Model
43
The design model can be viewed in two different dimensions.
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 dashed line indicates the boundary between the analysis and
design models.
In some cases, a clear distinction between the analysis and
design models is possible.
In other cases, the analysis model slowly blends into the design
and a clear distinction is less obvious.
44
Design Model Elements
Data elements
Data model --> data structures
Data model --> database architecture
Architectural elements
Application domain
Analysis classes, their relationships, collaborations and
behaviors are transformed into design realizations
Patterns and “styles”
Interface elements
the user interface (UI)
external interfaces to other systems, devices, networks or
other producers or consumers of information
internal interfaces between various design components.
Component elements
Deployment elements
45
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.
46
Architectural Design Elements
The architectural design for software is the
equivalent to the floor plan of a house.
The floor plan depicts the overall layout of the
rooms; their size, shape, and relationship to one
another; and the doors and windows that allow
movement into and out of the rooms.
The floor plan gives us an overall view of the
house.
Architectural design elements give us an
overall view of the software.
47
Architectural Design
Elements
The architectural model is derived from three
sources:
information about the application domain for the
software to be built;
specific requirements model elements such as data
flow diagrams or analysis classes, their relationships
and collaborations for the problem at hand, and
the availability of architectural patterns and styles.
48
Interface Design Elements
The interface design for software is analogous to a set of detailed drawings
(and specifications) for the doors, windows, and external utilities of a house.
These drawings depict the size and shape of doors and windows, the manner in
which they operate, the way in which utility connections (e.g., water, electrical,
gas, telephone) come into the house and are distributed among the rooms
depicted in the floor plan.
In essence, the detailed drawings (and specifications) for the doors, windows,
and external utilities tell us how things and information flow into and out of the
house and within the rooms that are part of the floor plan.
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.
49
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.
50
Interface representation for control panel
51
Component-Level Design Elements
The component-level design for software is the equivalent to a set
of detailed drawings (and specifications) for each room in a house.
These drawings depict wiring and plumbing within each room, the
location of electrical receptacles and wall switches, faucets, sinks,
showers, tubs, drains, cabinets, and closets.
They also describe the flooring to be used, the moldings to be
applied, and every other detail associated with a room.
The component-level design for software fully describes the
internal detail of each software component.
To accomplish this, the component-level design defines data
structures for all local data objects and algorithmic detail for all
processing that occurs within a component and an interface that
allows access to all component operations (behaviors).
52
A UML Component Diagram
SensorManagement
Sensor
53
a component named SensorManagement
(part of the SafeHome security function)
is represented.
A dashed arrow connects the component to a
class named Sensor that is assigned to it.
The SensorManagement component
performs all functions associated with
SafeHome sensors including monitoring and
configuring them.
54
Deployment-level design elements indicate how
software functionality and subsystems will be
allocated within the physical computing
environment that will support the software.
For example, the elements of the SafeHome
product are configured to operate within three
primary computing environments—a home-
based PC, the SafeHome control panel, and a
server housed at CPI Corp. (providing Internet-
based access to the system).
55
A UML Deployment Diagram
56
In the figure, three computing environments are shown (in
actuality, there would be more including sensors, cameras,
and others).
The subsystems (functionality) housed within each
computing element are indicated.
For example, the personal computer houses subsystems
that implement security, surveillance, home management,
and communications features.
In addition, an external access subsystem has been
designed to manage all attempts to access the SafeHome
system from an external source.
Each subsystem would be elaborated to indicate the
components that it implements.
57
Software Architecture
The software architecture of a program or
computing system is the structure or structures of
the system, which comprise software components,
the externally visible properties of those
components, and the relationships among them.
it is a representation that enables you to
(1) analyze the effectiveness of the design in meeting
its stated requirements,
(2) consider architectural alternatives at a stage when
making design changes is still relatively easy, and
(3) reduce the risks associated with the construction
of the software.
58
In the context of architectural design, a software component
can be something as simple as a program module or an object-
oriented class, but it can also be extended to include databases
and “middleware” that enable the configuration of a network
of clients and servers.
The properties of components are those characteristics that
are necessary for an understanding of how the components
interact with other components. At the architectural level,
internal properties (e.g., details of an algorithm) are not
specified.
The relationships between components can be as simple as a
procedure call from one module to another or as complex as a
database access protocol.
59
Why Is Architecture Important?
Representations of software architecture are an
enabler for communication between all parties
(stakeholders) interested in the development of a
computer-based system.
The architecture highlights early design decisions
that will have a profound impact on all software
engineering work that follows and, as important, on
the ultimate success of the system as an
operational entity.
Architecture “constitutes a relatively small,
intellectually graspable model of how the system is
structured and how its components work together”
60