Professional Documents
Culture Documents
AND MAINTENANCE
PRACTICAL
CONSIDERATIONS
1
Topics to be discussed
Construction design
Construction Languages
Coding
Construction Testing
Reuse
Construction Quality
Integration
2
CONSTRUCTION DESIGN
3
Software Design
4
Importance of Managing Complexity
Most technical issues are due to high complexity
Users are demanding more functionality
Frequent source of complexity
Software Crisis: Ability to produce suitable
applications is not keeping pace with demand
Causing systems to be unreliable, slow, insecure,
buggy
“Separation of concerns” is one method to overcome
complexity
Writing programs in terms of the problem domain,
rather than in terms of low-level implementation details
5
Overcome Complexity
6
Design Characteristics
1. Minimal complexity
2. Ease of maintenance
3. Loose coupling
4. Extensibility
5. High fan-in
6. Low-to-medium fan-out
7. Portability
8. Leanness
9. Stratification
10.Standard techniques
7
Minimal complexity
Avoid making “clever” designs. make “simple” and
“easy-to-understand” designs
Ease of maintenance
Designing for the maintenance programmer
Use common programming constructs and
consistent naming conventions
Loose coupling
Reduce interdependencies within the code
Extensibility
Minimal ripple effect when changes are made
Reusability
Modules, components, & subsystems can be and
are reused
8
High fan-in
Highly utilized classes
Low to medium fan-out
Call tree not to large
Portability
Able to be redeployed in a different environment
Leanness
No extra parts
Stratification
Consistent levels of abstraction across subsystems
Standard techniques
Stay with the “tried and true”
9
Levels of Design
10
Level 1 – Software System
11
Level 2 – Division into Subsystems or Packages
12
Level 3 – Division into Classes
13
Level 4 – Division into Routines
14
Level 5 – Internal Routine Design
15
Design Techniques
16
Aim for Strong Cohesion
Build Hierarchies
Formalize Class Contracts
Assign Responsibilities
Design for Test
Avoid Failure
Choose Binding Time Consciously
Make Central Points of Control
Consider Using Brute Force
Draw a Diagram
Keep Your Design Modular
17
Design Approaches
Iterate
Don’t stagnate in any one activity
Instead, cycle through activities and return to the beginning
Build on previous work
Divide and Conquer
Divide problem into more manageable chunks
Prototype
Create a “quick and dirty” version of the application
Provides insight into the problem
Collaborative Design
Two (or more) heads is better than one
Can be formal or informal
18
Construction Languages : Coding
19
Construction languages include all forms of
communication by which a human can specify an
executable problem solution to a computer.
Toolkit languages are used to build applications out of
toolkits and are more complex than configuration
languages.
Toolkit languages may be explicitly defined as
application programming languages (for example,
scripts), or may simply be implied by the set of
interfaces of a toolkit.
20
Programming languages are the most flexible type of
construction languages.
It contains the least amount of information about
specific application areas and development
processes, and so require the most training and skill
to use effectively.
21
There are three general kinds of notation used for
programming languages, namely:
Linguistic
Formal
Visual
22
Defensive Programming:
Approach to improve software quality by “Making
the software behave in a predictable manner despite
unexpected input or user actions
Protecting your program from Invalid Inputs
Assertions
Error Handling Techniques
Exceptions
23
Protecting Ur Program From Invalid
Inputs
A good program uses “garbage in, nothing out”; “garbage
in, error message out”; or “no garbage allowed in”
instead.
There are three general ways to handle garbage in:
25
An assertion usually takes two arguments: a Boolean
expression that describes the assumption that’s
supposed to be true and a message to display if it
isn’t.
Ex:
assert denominator != 0 : "denominator is
unexpectedly equal to 0.";
26
Error Handling Techniques
27
Return the same answer as the previous time
Substitute the closest legal value
Log a warning message to a file
Return an error code
Set the value of a status variable
Return status as the function’s return value
Throw an exception using the language’s built-in exception
mechanism
Call an error processing routine/object
centralize error handling in a global error handling routine
or error handling object.
Debugging Easy
28
Display an error message wherever the error is encountered
Shutdown
Some system shutdown when they detect error.
Useful in Critical Application
29
Correctness Vs Robustness
30
Exceptions
31
Include all information that led to the exception in the
exception message
If the exception was thrown because of an array
index error, be sure the exception message includes
the upper and lower array limits and the value of
the illegal index.
32
The Pseudo code Programming Process
Steps in building Classes and Routines
33
Steps in creating a Class
Create a general design for the class:
Define the class’s specific responsibilities.
Define what “secrets” the class will hide.
Determine whether the class will be derived from
another class, and whether other classes will be
allowed to derive from it.
Identify the class’s key public methods.
Identify and design any non- trivial data members used
by the class.
Construct each routine within the class
Review and test the class as a whole 34
Steps in building a routine
35
Pseudocode
36
Bad Pseudocode
37
Good Pseudocode
38
General issues in using Variables
Implicit Declarations
Ex : Visual Basic – Don’t declare compiler
declares(compiler settings)
Using a variable in body of a routine Have to
declare explicitly.
Turn off Implicit Declarations
Declare all Variables as you type in
Use naming Conventions
Check Variable names
39
Guidelines to Initialize Variables
40
Guidelines to Initialize variables
41
Guidelines to Initialize Variables
42
Using Conditionals
Simplest If / If – Then ;
If – then – else little more complex ;
chain of if –then –else –if more complex.
43
Plain if- then Statements
Put the normal case after the if rather than after the
else
44
Contd..,
Follow the if clause with a meaningful statement
Ex: Wrong way
if ( SomeTest )
;
else {
// do something
...
}
Proper way
if ( ! SomeTest ) {
// do something
...
}
45
Test the else clause for correctness
Check for reversal of the if and else clauses
46
Chains of if-then-else Statements
Simplify complicated tests with boolean function calls
if ( inputCharacter < SPACE ) { {
characterType = characterType =
CharacterType_ControlCharacter; CharacterType_Punctuation;
} }
else if ( '0' <= inputCharacter &&
else if ( inputCharacter <= '9' ) {
inputCharacter == ' ' || characterType = CharacterType_Digit;
inputCharacter == ',' || }
inputCharacter == '.' || else if (
inputCharacter == '!' || ( 'a' <= inputCharacter &&
inputCharacter <= 'z' ) ||
inputCharacter == '(' ||
( 'A' <= inputCharacter &&
inputCharacter == ')' || inputCharacter <= 'Z') ) {
inputCharacter == ':' || characterType = CharacterType_Letter;
inputCharacter == ';' || }
inputCharacter == '?' ||
inputCharacter == '-'
47
Contd..,
Put the most common
cases first :
if ( IsControl( inputCharacter ) ) {
if ( IsLetter( inputCharacter ) ) {
characterType =
CharacterType_ControlCharacter; characterType = CharacterType_Letter;
}
}
else if ( IsPunctuation( inputCharacter ) ) {
else if ( IsPunctuation( inputCharacter ) )
characterType
{ =CharacterType_Punctuation;
characterType = }
CharacterType_Punctuation; else if ( IsDigit( inputCharacter ) ) {
} characterType = CharacterType_Digit;
else if ( IsDigit( inputCharacter ) ) { }
characterType = CharacterType_Digit; else if ( IsControl( inputCharacter ) ) {
} characterType
=CharacterType_ControlCharacter;
else if ( IsLetter( inputCharacter ) ) {
}
characterType = CharacterType_Letter;
} 48
Contd..,
49
Selecting the Kind of Loop
50
Usage of Loops
51
Usage of Loops
When to use For loops????
Need a loop that executes for a specified number
of time
Use for loop for simple activities that don’t
require internal loop controls.
When the loop controls involves simple increment
and decrement.
In For need not to do anything to control it, if
there’s a condition where the execution has to jump
out of loop use While.
For is for simple activities whereas while is for
complicated looping tasks
52
CONSTRUCTION TESTING
53
Design principles for Construction testing
55
The purpose of construction testing is to reduce
the gap between the time at which faults are
inserted into the code and the time those faults are
detected.
In some cases, construction testing is performed
after code has been written. In other cases, test
cases may be created before code is written.
56
Verification and Validation
58
Two Software Evaluation Metrics
1. Cohesion
2. Coupling
59
COHESION: The measure of strength of the
interrelatedness of statements within a module
Functional: one action or goal
• Informational: multiple independent actions on
the same data
Communicational: series of steps on same data
Procedural: series of steps for an action
• Temporal: series of related actions related in time
• Logical: series of related actions
• Coincidental: multiple, unrelated actions
60
Cohesion
61
COUPLING: The measure of strength of the
connection between modules
Content: direct branch into middle of module
No Coupling
62
Coupling
63
TESTING PRINCIPLES
User-accepted test plan
General testing strategy/philosophy:
Cause and discover errors
Rules of reasonableness should prevail
Testing Strategies:
Top-Down
Bottom-Up
Middle-out
Hybrid
Black box
White box
Alpha
Beta 64
Testing Methodology
User Acceptance Testing
System Testing
component Testing
Integration Testing
Unit Testing
65
Unit testing
execution of a complete class, routine, or small
program that has been written by a single
programmer.
Integration testing
Combined execution of two or more classes,
packages, components, subsystems that have been
created by multiple programmers or programming
teams.
Component Testing
execution of a class, package, small program, or
other program element that involves the work of
multiple programmers or programming teams.
66
System testing
execution of the software in its final configuration.
Regression testing
Repetition of previously executed test cases for the
purpose of finding defects in software that
previously passed the same set of tests.
67
Reuse
68
Task related to reuse
69
Construction Quality
70
Definitions
The totality of features and characteristics of a
product or service that bear on its ability to satisfy
stated or implied needs.
Software has both external and internal quality
characteristics.
The degree to which a system, component, or
process meets specified requirements
A product that satisfies the stakeholders needs
(Compliant Product + Good Quality + Delivery
Within Budget/Schedule.)
71
Internal Characteristics
72
efficiency - the speed and compactness of the
software
usability - the ability to use the software easily
testability - the ability to construct and execute
test cases easily
portability - the ability to move the software
easily from one environment to another and of
course
functionality – what the product does
73
Quality and Software Construction
Functionality [+ usability]
Build software as early as possible and give it to
the user
As often as possible
Reliability [correctness + robustness]
Run and test the software
As often as possible
Reusability [modifiability + extendibility]
Redesign and improve the source code
74
Techniques for improving code quality
75
Defect – Detection Rates
76
Model defect rates are not above 65% of any single
technique
Code inspections found a 60% model defect rate
The model defect rate for [the popular] unit testing is
only 25%
Code reading detected more interface defects;
functional testing detected more control defects
To improve defect detection use more than one
technique
The earlier a defect is caught, the cheaper it is to fix
Approximately 50% of the construction phase is
spent debugging finished code and finding errors
77
The primary techniques used for
construction include
Unit testing and integration testing
Test-first development
Code stepping
Use of assertions
Debugging
Technical reviews
Static analysis
78
Goals
79
Integration
80
Large projects - hooking sets of programs
together; weeks or month together.
81
Construction integration include
82
System Integration
83
Types of Integration techniques
84
The Big Bang Integration
All components, modules, and subsystems are
combined and integrated at one time
Incremental integration:
1. Develop a small core of the system
2. Test and debug it
3. Design, code, test, and debug another part
(module, routine, etc.)
4. Integrate the new part with the core
5. Ensure that the new partial system works
6. Repeat steps 3 through 5 until finished
86
Benefits of Incremental Integration
88
The order of development depends on the type of
project
Control oriented: Calling routines are higher than
called routines
Data oriented: Routines that primarily set data higher
than routines that primarily use data
Requirements oriented: Routines least sensitive to
requirements or design choices are ranked higher than
more sensitive routines
Test oriented: Routines critically needed for testing of
other routines are higher ranked than routines not
needed for testing
89
Difficulty oriented: Harder routines are ranked
higher than easier routines (This is the order that is
illustrated)
90
Top-Down vs. Bottom-Up
Integration
91
Phased Integration Vs Incremental
Integration
92
Phased Integration Vs Incremental
Integration
Errors are easy to locate
The system succeeds early
in the project
The system succeeds early
in the project
You’ll improve customer
relations
The units of the system
are tested more fully
You can build the system
with a shorter
development schedule
93
Other Approaches
94