Design Engineering
Design Engineering
Design Engineering
Introduction: Software design encompasses the set of principles, concepts, and
practices that lead to the development of a high-quality system or product. Design
principles establish an overriding philosophy that guides you in the design work
you must perform. Design is pivotal to successful software engineering
The goal of design is to produce a model or representation that exhibits
firmness, commodity, and delight Software design changes continually as new
methods, better analysis, and broader understanding evolve
DESIGN WITHIN THE CONTEXT OF SOFTWARE ENGINEERING
generate code and for those who test and subsequently support the software.
• The design should provide a complete picture of the software, addressing
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,
Separation of Concerns
Separation of concerns is a design concept that suggests that 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.
Separation of concerns is manifested in other related design concepts:
modularity, aspects, functional independence, and refinement. Each will be
discussed in the subsections that follow.
8.3.5 Modularity
Modularity is the most common manifestation of separation of concerns.
Software is divided into separately named and addressable components, sometimes
called module.
Modularity is the single attribute of software that allows a program to be
intellectually manageable
Fig : Modularity and software cost
Information Hiding
The principle of information hiding suggests that modules be “characterized by
design decisions that hides from all others.” In other words, modules should be
specified and designed so that information contained within a module is
inaccessible to other modules that have no need for such information.The use of
information hiding as a design criterion for modular systems provides the greatest
benefits when modifications are required during testing and later during software
maintenance. 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.
Functional Independence
The concept of functional independence is a direct outgrowth of separation
of concerns, modularity, and the concepts of abstraction and information hiding.
Functional independence is achieved by developing modules with “single minded”
function and an “aversion” to excessive interaction with other modules.
Independence is assessed using two qualitative criteria: cohesion
and coupling. Cohesion is an indication of the relative functional strength
of a module. Coupling is an indication of the relative
interdependence among modules.
Cohesion is a natural extension of the information-hiding concept. 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
do just one thing. Although you should always strive for high cohesion (i.e.,
single-mindedness).
Coupling is an indication of interconnection among modules in a software
structure. Coupling depends on the interface complexity between modules, the
point at which entry or reference is made to a module, and what data pass across
the interface. In software design, you should strive for the lowest possible
coupling.
Refinement
Stepwise refinement is a top-down design strategy originally proposed by
Niklaus Wirth. Refinement is actually a process of elaboration. You begin with a
statement of function that is defined at a high level of abstraction.
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.
Aspects
An aspect is a representation of a crosscutting concern. A crosscutting concern is
some characteristic of the system that applies across many different requirements.
Refactoring
An important design activity suggested for many agile methods, refactoring is a
reorganization technique that simplifies the design (or code) of a component
without changing its function or behavior. Fowler defines refactoring in the
following manner: “Refactoring is the process of changing a software system in
such a way that it does not alter the external behavior of the code [design] yet
improves its internal structure.”
Object-Oriented Design Concepts
The object-oriented (OO) paradigm is widely used in modern software
engineering. OO design concepts such as classes and objects, inheritance,
messages, and polymorphism, among others.
Design Classes
The requirements model defines a set of analysis classes. Each describes some
element of the problem domain, focusing on aspects of the problem that are user
visible. 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 thedesign architecture, can be developed:
• User interface classes define all abstractions that are necessary for human
computer interaction (HCI). The design classes for the interface may be
visual representations of the elements of the metaphor.
• 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
enables data mining or knowledge discovery that can have an impact on the
success of the business itself.
of how the system is structured and how its components work together” The
architectural design model and the architectural patterns contained within it
are transferable.
Architectural Descriptions
An architectural description of a software-based system must exhibit
characteristics that are analogous to those noted for the office building.
The IEEE Computer Society has proposed, Recommended Practice
for Architectural Description of Software-Intensive Systems, with the
following objectives:
(1) to establish a conceptual framework and vocabulary for use
during the design of software architecture,
(2) to provide detailed guidelines for representing an architectural description,
and
(3) to encourage sound architectural design practices.
The IEEE standard defines an architectural description (AD) as “a
collection of products to document an architecture.” The description itself is
represented using multiple views, where each view is “a representation of a
whole system from the perspective of a related set of concerns.”
Architectural Decisions
Each view developed as part of an architectural description addresses
a specific stakeholder concern. To develop each view (and the architectural
description as a whole) the system architect considers a variety of
alternatives and ultimately decides on the specific architectural features that
best meet the concern. Therefore, architectural decisions themselves can be
considered to be one view of the architecture. The reasons that decisions
were made provide insight into the structure of a system and its conformance
to stakeholder concerns.
ARCHITECTURAL GENRES
The architectural genre will often dictate the specific architectural
approach to the structure that must be built. In the context of architectural design,
genre implies a specific category within the overall software domain. Within each
category, you encounter a number of subcategories. Grady Booch suggests the
following architectural genres for software-based systems:
• Artificial intelligence—Systems that simulate or augment human
Coupling
Coupling is a qualitative measure of the degree to which classes are
connected to one another. As classes (and components) become more
interdependent, coupling increases. An important objective in
component-level design is to keep coupling as low as is possible.
Class coupling can manifest itself in a variety of ways. Lethbridge
and Laganiére define the following coupling categories:
Content coupling. Occurs when one component “surreptitiously
modifies data that is internal to another component”.
Common coupling. Occurs when a number of components all make
use of a global variable. Although this is sometimes necessary,
common coupling can lead to uncontrolled error propagation and
unforeseen side effects when changes are made.
Control coupling. Occurs when operation A() invokes operation B() and
passes a control flag to
B. The control flag then “directs” logical flow within B. The problem
with this form of coupling is that an unrelated change in B can result
in the necessity to change the meaning of the control flag that A
passes. If this is overlooked, an error will result.
Stamp coupling. Occurs when ClassB is declared as a type for an
argument of an operation of ClassA. Because ClassB is now a part
of the definition of ClassA, modifying the system becomes more
complex.
Data coupling. Occurs when operations pass long strings of data
arguments. The “bandwidth” of communication between classes and
components grows and the complexity of the interface increases.
Testing and maintenance are more difficult.
Routine call coupling. Occurs when one operation invokes another.
This level of coupling is common and is often quite necessary.
However, it does increase the connectedness of a system.
Type use coupling. Occurs when component A uses a data type
defined in component B. If the type definition changes, every
component that uses the definition must also change.
Inclusion or import coupling. Occurs when component A imports
or includes a package or the content of component B.
External coupling. Occurs when a component communicates or
collaborates with infrastructure components. Although this type of
coupling is necessary, it should be limited to a small number of
components or classes within a system.
Software must communicate internally and externally.
Therefore, coupling is a fact of life. However, the designer should
work to reduce coupling whenever possible.
CONDUCTING COMPONENT-LEVEL DESIGN
HIPO Diagram
Example
Both parts of HIPO diagram, Hierarchical presentation and IPO Chart are used
for structure design of software program as well as documentation of the same.
Structure Charts
Structure chart is a chart derived from Data Flow Diagram. It represents the
system in more detail than DFD. It breaks down the entire system into lowest
functional modules, describes functions and sub-functions of each module of
the system to a greater detail than DFD.
Structure chart represents hierarchical structure of modules. At each layer a
specific task is performed.
Here are the symbols used in construction of structure charts -
Module - It represents process or subroutine or task. A control
module branches to more than one sub-module. Library Modules are
and invokable from any module.
re-usable
Condition - It is represented by small diamond at the base of module.
It depicts that control module can select any of sub-routine based on
some condition.
Jump - An arrow is shown pointing inside the module to depict that
Data flow - A directed arrow with empty circle at the end represents data
flow.
Control flow - A directed arrow with filled circle at the end represents
control flow.
Decision Trees
Decision trees are a method for defining complex relationships by describing
decisions and avoiding the problems in communication. A decision tree is a
diagram that shows alternative actions and conditions within horizontal tree
framework. Thus, it depicts which conditions to consider first, second, and so
on.
Decision trees depict the relationship of each condition and their permissible
actions. A square node indicates an action and a circle indicates a condition. It
forces analysts to consider the sequence of decisions and identifies the actual
decision that must be made.
The major limitation of a decision tree is that it lacks information in its format
to describe what other combinations of conditions you can take for testing. It is
a single representation of the relationships between conditions and actions.
For example, refer the following decision tree −
Decision Tables
Purchase amount = - Y Y
Rs 10,000/-
Regular Customer - Y N
ACTIONS
Give 5% discount X X -
Give no discount - - X
Structured Flowchart
Structures
You can make your flowcharts easier to understand and less subject to errors by
using only a fixed set of structures. These structures include:
Sequence
Decision
Loop
Case
Scroll to the Flowcharting folder and click the plus sign to open it.
Click the Colored Edge Shapes stencil and then click the Add Stencil button.
Sequence
The flowchart above demonstrates a sequence of steps. The reader would start
at the Start shape and follow the arrows from one rectangle to the other,
finishing at the End shape. A sequence is the simplest flowcharting
construction. You do each step in order.
If your charts are all sequences, then you probably don't need to draw a
flowchart. You can type a simple list using your word processor. The power of
a flowchart becomes evident when you include decisions and loops.
RFFlow allows you to number your shapes if you wish. Run RFFlow and click
on Tools, Number Shapes, and put a check mark in Enable numbers for the
entire chart. You can also choose to have a number or not in each individual
shape and you can quickly renumber your chart at any time.
Decision
This structure allows you to repeat a task over and over. The red chart above on
the left does the task and repeats doing the task until the condition is false. It
always does the task at least once. The green chart on the right checks the
condition first and continues doing the task while the condition is true. In the
green chart the task may not be done at all. You can also have the conditions
reversed and your loop is still a structured design loop.
The above chart is a "For Loop." In this example the task is performed 10 times
as X counts from 0 to 10. Depending on the condition, the task may not be
performed at all.
There is also a "For Each" structure that is like the for loop, but has no counter.
It will go through each item of a collection and do the task. You don't have to
know the length of the collection or use a counter. It is essentially saying "do
this for every item in the collection".
Case
The structure above is called the case structure or selection structure. The
decision works fine if you have only two outputs, but if there are several, then
using multiple decisions makes the chart too busy. Since the case structure can
be constructed using the decision structure, it is superfluous, but useful. The
case structure helps make a flowchart more readable and saves space on the
paper.
Other Good Design Practices
Start and End
Each flowchart must have one starting point. It can have multiple ending points,
but only one starting point. The same terminal shape is used for the start and
end. The terminal shape is a rectangle that is semicircular on the left and right
as shown above. You can use other words instead of start and end, like begin
and finish, or any words with a similar meaning. Some companies use an oval
instead of a terminal shape. The bottom line is that it should be clear to the
person looking at the chart where the chart starts and where it ends.
Connector Block and Off Page Connector
Pseudo-Code
Pseudo code is written more close to programming language. It may be
considered as augmented programming language, full of comments and
descriptions.
Pseudo code avoids variable declaration but they are written using some actual
programming language’s constructs, like C, Fortran, Pascal etc.
Pseudo code contains more programming details than Structured English. It
provides a method to perform the task, as if a computer is executing the code.
Example
Program to print Fibonacci up to n numbers.
void function Fibonacci
Get value of n;
Set value of a to 1;
Set value of b to 1;
Initialize I to 0
for (i=0; i< n; i++)
{
if a greater than b
{
Increase b by a;
Print b;
}
else if b greater than a
{
increase a by b;
print a;
}
}
Nassi-Shneiderman Diagram
Nassi-Shneiderman diagrams (aka, NS diagrams or structograms), are used to
outline structured programs. They are not very common in industry today but
are sometimes used as a computer science teaching tool, often as an alternate to
flowcharts. A simple example is shown below.
Sample Nassi-Shneiderman diagram
Nassi-Shneiderman Shapes
Process
Branches
Multiple branches,
such as a switch-case statement.
Default case is the short leg of the triangle.
Loops
Nassi-Shneiderman
Diagram in Excel
Adding a bunch of shapes to the diagram is fairly straightforward. (Well,
except for the Branch triangle, which is a pain. We'll show why below.) Since
the default shape style in Excel is dark blue with centered text, we will create
some baseline shapes with plain styling that we place off to the side and then
copy and paste to build the diagram.
Create a Grid
Before adding shapes, the first step is to create a grid and then turn on Snap
to Grid. These steps are covered in the How to Flowchart in Excel article, so
we won't repeat them here.
Create a Baseline Process Block
Click the Insert tab, then click the Shapes dropdown and select either a
Rectangle from the Basic Shapes group or a Process shape from the Flowchart
group. Use you left mouse button to draw it to size on the sheet. With the shape
still selected, right-click on the shape and select Format Shape from the context
menu. Follow these steps to set the styling:
On the Format Shape dialog, select Fill from the left menu. Choose
the Solid fill option and use the Color dropdown to set the color to
white.
Next, select Line Color from the left menu. Choose the Solid line
option and use the Color dropdown to set the color to black.
Next, select Line Style from the left menu. Change the Width setting to
0.75 pt.
Click the Close button
Type "text" (or some othert placeholder text) into the shape.
With the shape still selected, click the Home tab, and use the font,
font size, and font color toolbar controls to set the font as desired.
Right-click on the shape again and select Set as Default Shape from the
menu. Despite the misleading menu label, this sets the default style,
not the default shape type. Now all shapes added will use this
1. Add the Isoceles triangle as you did the process rectangle before.
2. Next, right-click on the triangle and select Size and Properties from
the menu.
3. On the size dialog, change the Rotation to 180°.
Textbox:
Final Edit:
Once shapes are grouped you can select individual shapes within the group by
first clicking on the group to select it, and then clicking again on the individual
shape. Do this now to select the textbox. Right-click on the textbox and use the
Format Shape dialog to change the Fill to None and the Line Color to No line.
You now have a reusable branch element.
Editing Tips
Triangle adjustment
Adjustment results
The multi-key shortcuts look odd compared to most keyboard shortcuts, but
when you hold the Alt key, Excel hightlights them on the screen making the
path becomes obvious. The letters map to characters in each word, even
though they are not underlined like menu systems. For example, Send to Back
is Page Layout > Arrange > Send Backward > Send to Back.
Selecting Shapes
You can select shapes with your mouse and use the Tab key to toggle between
selected shapes. To select multiple shapes, click the first shape and then hold
the Shift key down as you click on the others. You can also use a special
Select Objects cursor available on the Home tab under the Find & Select
menu. You need to toggle this cursor off to resume normal mouse usage - via
the menu or by double-clicking anywhere on the worksheet.
Moving Shapes
Clicking and dragging with the mouse is the most obvious way, but you can
also use the keyboard arrow keys to move a shape around. With Snap to Grid
on, shapes will snap to the next cell as you do this.
Changing Text Alignment
On the Home tab, use the standard horizontal and vertical text alignment
buttons.