Professional Documents
Culture Documents
Software Engineering
(Compulsory)
IT3205 - Software Design
Coding
Duration: 3 hours
UCSC - 2014 2
IT3205 - Software Design
Learning Objectives
• Select appropriate programming language and
development tools for a given problem •
Identify the features of a good program, good
programming practices and program
documentation
UCSC - 2014 3
IT3205 - Software Design
Detailed Syllabus
5.1 Programming languages and development tools
UCSC - 2014 6
IT3205 - Software Design
Coding
• The goal of the coding is to implement the design in
the best possible manner.
• Coding activity affects both testing and maintenance
phases.
UCSC - 2014 7
IT3205 - Software Design
5.1 PROGRAMMING
UCSC - 2014 8
IT3205 - Software Design
TOOLS
UCSC - 2014 9
Language
IT3205 - Software Design
Features
This table describes the strengths and weaknesses of some of the more important
languages in current use.
Language Features Strengths Weaknesses
Ada - Procedural - Strong type checking - Large run time system - Some object
reduces errors on requires. orientation built in applications. -
Expensive to develop exception handling. - US DOS support applications.
- Strong type checking - Good for safety critical - Requires powerful
- No pointers and military machine to run on.
- Defined standards applications. - Compliers meet the defined standards.
C - Procedural - Widely used different, don’t meet
- Weak type checking - Poor exception standard.
- Very low level pointers handling support. -
- Flexible Memory handling
- Close to hardware/OS - Fast and leads to unreliable
efficient applications can be built. code. - Compilers all
UCSC - 2014 10
Language
IT3205 - Software Design
Features
Language Features Strengths Weaknesses
C++ - OO extension to C. - All those of C and OO - As for C and can simple
- Weak type checking concepts of write C.
- Flexible Polymorphism,
- Pointers Inheritance (single &
multiple), Encapsulation
etc.
COBOL - Procedural - Suited to batch TP - Large run time system
- Strong I/O handling for applications required.
transaction processing - Widely used - Old - many features
(TP). - Most 4GLs interface to simply added on later.
- Defined standards COBOL. - Not all compilers meet
standard.
Fortran - Procedural - Suited to data analysis - Old - more modern
- Strong arithmetic where significant languages provide most of
support through arithmetic processing the features.
libraries. required.
Language
IT3205 - Software Design
Features
Language Features Strengths Weaknesses
Java - Object Oriented - Good user interface Controlled by a
- Better type checking than C but and network support commercial
still reasonably weak. - Standard through libraries. - organization.
defined by Sun Microsystems. Ideal for network
- Platform independent. - Dynamic - Requires own run
downloading of classes. time environment. -
Pascal - Procedural applications. Good OO concepts in user
- Strong type checking teaching language interface handling.
- Defined standard - Widely usedUCSC - 2014
- Not widely used in
Visual - Simple procedural industry - Poor
- Suited to small
Basic language. environment support
applications and
- Interpreted - Extensive Windows - Performance
prototyping. - Some
programming support
UCSC - 2014 12
Language
IT3205 - Software Design
Features
- Complex data structures cannot 11
be modeled.
Language
IT3205 - Software Design
Features
TOOLS
Selecting Languages and Tools
• There's no language suitable for all tasks, and there probably won't ever
be one.
UCSC - 2014 15
IT3205 - Software Design
Coding Practices
• Allow code to be written in a more predictable and
maintainable fashion.
UCSC - 2014 16
IT3205 - Software Design
UCSC - 2014 17
IT3205 - Software Design
UCSC - 2014 18
IT3205 - Software Design
– Fault tolerance
• Aims to produce code that will continue to function in
the presence of errors.
• Fault tolerance includes:
– Exception Handling
UCSC - 2014 19
IT3205 - Software Design
– Defensive programming
– Fault recovery
Exception Handling
• An exception is an error or unexpected event.
Traditional languages, Pascal, C etc. have no specific
support for handling exceptions, newer languages,
Ada, Java, have some in built exception handling.
UCSC - 2014 20
IT3205 - Software Design
Example:
– Procedure A calls Procedure B
– Procedure B calls Procedure C
– An exception occurs in procedure C
– B cannot continue
– Need to signal exception to A
Exception Handling
• With traditional languages we must resort to setting
error or status variables which can be shared or
passed from procedure to procedure, for example:
UCSC - 2014 21
IT3205 - Software Design
Exception Handling
With Java exception handling is built into the language
UCSC - 2014 22
IT3205 - Software Design
UCSC - 2014 23
IT3205 - Software Design
Defensive programming
• Assume that there are faults and inconsistencies in the
system and validate data.
• Example checks are:
– internal data states, for example probabilities between 0 and 1,
money = integer + 2 decimal places etc.
– checksums
– array bounds checking
– division by 0
– pointer validation - check that pointer is allocated and points to a data
structure.
– If any problems occur then the system must recover to a safe state.
UCSC - 2014 24
IT3205 - Software Design
Fault recovery
• Forward recovery, correct damaged system
state • Error detection and correction of
coded data • File or database recovery •
Backward recovery, restore system to a safe
state • Database transaction roll-back
Programming for readability
• One of the major problems with reviewing and
maintaining code is that the code is unreadable.
UCSC - 2014 25
IT3205 - Software Design
Naming conventions
• It is important on projects of more than one person or on the
development of software applications which are to be
UCSC - 2014 26
IT3205 - Software Design
Naming conventions
• This is true during the development phase, when reviews and
such like are carried out, and during the maintenance phase
UCSC - 2014 27
IT3205 - Software Design
Naming conventions
• Example naming conventions for the 'C' language might be:
1. All constant names are in upper case and begin C, for example
C_SPEED_OF_LIGHT
UCSC - 2014 28
IT3205 - Software Design
Naming conventions
• Example naming conventions for the 'C' language might be:
UCSC - 2014 29
IT3205 - Software Design
UCSC - 2014 30
IT3205 - Software Design
Data types
• Use abstract data types to make the code
clearer.
Example:
Type TrafficLightColour is (red, amber, green);
ColourShowing, NextColour: TrafficLightColour;
UCSC - 2014 31
IT3205 - Software Design
Control constructs
• Use the standard flow control constructs for
structured programming, sequence, selection
and iteration, flow should be from the top of
the program down.
• Loops, decision statements, routines etc.
should all have single entry and exit points,
avoid gotos, breaks,exits etc.
• Functions should have a single return.
UCSC - 2014 32
IT3205 - Software Design
Control constructs
• Keep code simple - one possible complexity heuristic
is;
1. Start with 1 for the straight path through the routine
2. Add 1 for each control keyword, if, while, repeat, and, or
etc.
3. Add 1 for each keyword in a case. If the case does not have
a default it should.
UCSC - 2014 33
IT3205 - Software Design
Technical considerations
• Environment
– the language should support the features of the environment in which
the application is to run, for example if the application is to run on the
Windows operating system then the programming language and
development tools should help to reduce the effort required to
produce the user interface, that is use Visual C++ or Borland C++
rather than a basic C compiler and the Windows SDK.
• Language support
UCSC - 2014 34
IT3205 - Software Design
Technical considerations
• Performance
– applications which have critical speed and size performance
requirements cannot usually be built using an interpreted language
such as Basic or a language which requires a complex run time system
such as Smalltalk or Java as the overhead in the run time system is too
great.
• Safety / security
UCSC - 2014 35
IT3205 - Software Design
Non-technical considerations
Here we must look at the project as a whole and the business
objectives of the organization. It should be noted that these
considerations are typically more important than the purely
technical factors.
UCSC - 2014 36
IT3205 - Software Design
• Timescales
– the project timescales may restrict the choice of languages, for
example selecting a language known by the programmers will reduce
timescales, or help to meet timescales.
• Maintenance
– if the application is to be passed on to a maintenance team then the
skills of the maintenance team and the nature of the other
applications being maintained may have a bearing on the language
chosen. Do you want to have to re-train the maintenance staff?
Non-technical considerations
• Other applications
UCSC - 2014 37
IT3205 - Software Design
• Available tools
– what compilers, debuggers are currently available in the workplace?
Buying new software to support the development may increase the
development costs significantly.
Non-technical considerations
• Risk
– adopting new technology always carries an associated risk, on a
project which is critical to the business such risks may be
unacceptable.
• Morale
UCSC - 2014 38
IT3205 - Software Design
UCSC - 2014 39
IT3205 - Software Design
UCSC - 2014 40
IT3205 - Software Design
UCSC - 2014 41
IT3205 - Software Design
Code Reviews
• A code review is also called technical review.
• The code review for a module is carried out after the
module is successfully compiled and all the syntax
errors eliminated.
UCSC - 2014 42
IT3205 - Software Design
UCSC - 2014 43
IT3205 - Software Design
UCSC - 2014 44
IT3205 - Software Design
Code Reviews
• Code reviews can often find and remove
common vulnerabilities such as format string
exploits, race conditions, memory leaks and
buffer overflows, thereby improving software
security.
• Improve the quality of the code being
reviewed • Improve programmers
UCSC - 2014 45
IT3205 - Software Design
Code Reviews
• A code review is not a meeting to;
– negatively criticize someone else's code
– criticize architecture or design (unless it is an
architectural or design review)
– criticize a colleague
– determine whether someone is to be removed
from a project or not
UCSC - 2014 46
IT3205 - Software Design
UCSC - 2014 47
IT3205 - Software Design
specifications
Code Walkthrough
• This an informal code analysis technique. In this
technique when a module has been coded, it is
compiled and eliminate all syntax errors.
UCSC - 2014 48
IT3205 - Software Design
Code Inspection
• Software maintenance is the general process of
changing a system after it is diverted.
UCSC - 2014 49
IT3205 - Software Design
Code Inspection
• Errors detected during code inspection;
– Use of uninitialized variables
UCSC - 2014 50
IT3205 - Software Design
– Jumps in to loops
– Non terminating loops
– Incompatible assignments
– Array indices out of bounds
– Improper storage allocation and deallocation
– Mismatches between actual and formal parameters in
procedure calls
– Improper modification of loops
UCSC - 2014 51
IT3205 - Software Design
IT3205: Fundamentals of
Software Engineering
(Compulsory)
UCSC - 2014 52
IT3205 - Software Design
IT3205: Fundamentals of
Software
Engineering
UCSC - 2014 53
IT3205 - Software Design
Learning Objectives
• State the software testing process and required
documentation
• Explain the different software testing techniques and
integration strategies
• Design test cases and write test programs for a given simple
software problem
• Describe the code verification techniques
• Describe the importance of software quality
• Distinguish the difference between product quality and
process quality
UCSC - 2014 54
IT3205 - Software Design
Detailed Syllabus
6.1 Verification and Validation
6.2 Techniques of testing
6.2.1 Black-box and White-box testing
6.2.2 Inspections
6.3 Levels of testing
6.3.1 Unit testing
6.3.2 Integration Testing
6.3.3 Interface testing
6.3.4 System testing
UCSC - 2014 55
IT3205 - Software Design
Detailed Syllabus
6.3 Levels of testing
6.3.6 Regression testing
6.3.7 Back-to-back testing and Thread testing
6.3.8 Statistical Software Testing
6.3.9 Object Oriented Testing
6.4 Design of test cases
6.5 Quality management activities
6.6 Product and process quality
6.7 Standards
UCSC - 2014 56
IT3205 - Software Design
6.7.1 ISO9000
6.7.2 Capability Maturity Model (CMM)
UCSC - 2014 57
IT3205 - Software Design
UCSC - 2014 58
IT3205 - Software Design
UCSC - 2014 59
IT3205 - Software Design
UCSC - 2014 60
IT3205 - Software Design
failure. Test results for all passes through the test plan must
be recorded to allow accurate records to be kept of where problems
occur and when they were identified and corrected.
Testing Process
1. Run the tests as defined by the test plan.
Note: Testing should not stop when the first problem is encountered,
unless it is so severe that the rest of the tests would be meaningless.
Rather all testing in the test plan should be carried out and then the
errors addressed.
2. Record the outcome of each test in the test report, both success
and failure should be reported. For failed tests the nature of the
UCSC - 2014 61
IT3205 - Software Design
UCSC - 2014 62
IT3205 - Software Design
• Static verification
– Concerned with analysis of the static system
representation to discover problems
• does not include execution
UCSC - 2014 63
IT3205 - Software Design
UCSC - 2014 64
IT3205 - Software Design
Unit Testing
UCSC - 2014 65
Sub-System
IT3205 - Software Design
UCSC - 2014 66
IT3205 - Software Design
UCSC - 2014 67
IT3205 - Software Design
Black-box Testing
• Approach to testing where the program is considered as a
‘black-box’
• The program test cases are based on the system
specification
UCSC - 2014 68
IT3205 - Software Design
UCSC - 2014 69
IT3205 - Software Design
Black-box Testing
UCSC - 2014 70
IT3205 - Software Design
UCSC - 2014 71
IT3205 - Software Design
White-box Testing
• Sometimes called Structural testing or glass box testing
• Derivation of test cases according to program structure.
• Knowledge of the program used to identify additional test
cases
• Objective is to exercise all program statements (not all path
combinations)
UCSC - 2014 72
IT3205 - Software Design
UCSC - 2014 73
IT3205 - Software Design
Structural testing
UCSC - 2014 74
IT3205 - Software Design
UCSC - 2014 75
IT3205 - Software Design
Software Inspection
• Inspection techniques include,
– Program inspections
– Automated source code analysis
– Formal verification
• Can only check the correspondence between a
program and its specification (verification)
• Unable to demonstrate that the software is
operationally useful.
UCSC - 2014 76
IT3205 - Software Design
Software Inspection
• Inspections not require execution of a system so
may be used before implementation.
• They have been shown to be an effective
technique for discovering program errors.
– Many different defects may be discovered in a single
inspection. In testing, one defect may mask another, so
several executions are required.
UCSC - 2014 77
IT3205 - Software Design
UCSC - 2014 78
IT3205 - Software Design
UCSC - 2014 79
IT3205 - Software Design
Inspection Pre-conditions
• A precise specification must be available.
• Team members must be familiar with the
organization standards.
• Syntactically correct code or other system
representations must be available.
• An error checklist should be prepared.
UCSC - 2014 80
IT3205 - Software Design
UCSC - 2014 81
IT3205 - Software Design
UCSC - 2014 82
IT3205 - Software Design
UCSC - 2014 83
IT3205 - Software Design
UCSC - 2014 84
IT3205 - Software Design
Inspection Checks
Data faults Are all program variables initialized before their values are used?
Have all constants been named? Should the upper bound of
arrays be equal to the size of the array or Size -1? If character
strings are used, is a delimiter explicitly assigned? Is there any
possibility of buffer overflow?
Control faults For each conditional statement, is the condition correct? Is each
loop certain to terminate? Are compound statements correctly
bracketed? In case statements, are all possible cases accounted
for? If a break is required after each case in case statements, has
it been included?
Input/output faults Are all input variables used? Are all output variables assigned a
value before they are output? Can unexpected inputs cause
corruption?
UCSC - 2014 85
IT3205 - Software Design
Inspection Checks
UCSC - 2014 86
IT3205 - Software Design
Interface faults Do all function and method calls have the correct number of
parameters? Do formal and actual parameter types match? Are
the parameters in the right order? If components access shared
UCSC - 2014 memory, do they have the same model of the shared memory87
IT3205 - Software Design
UCSC - 2014 88
IT3205 - Software Design
Test Phases
UCSC - 2014 89
IT3205 - Software Design
Test Phases
UCSC - 2014 91
IT3205 - Software Design
Unit Testing
• Unit Testing is carried out as a part of the coding
task. This phase is based on the design of the
software for a piece of code. Unit testing should
prove the following about the code
– Robust –the code should not fail under any
circumstances.
– Functionally correct –the code should carry out the task
defined by the code design.
– Correct interface –the inputs and outputs from the
code should be as defined in the design.
UCSC - 2014 93
IT3205 - Software Design
UCSC - 2014 94
IT3205 - Software Design
Integration/Sub-systems Testing
• Integration Testing is carried out after the separate
software modules have been unit testing.
Integration testing is based on the functional
specification of the software. Integration testing
should prove the following about the software:
– Integration -the modules of the system should interact
as designed.
– Functionally correct -the system should behave as
defined in the functional specification.
UCSC - 2014 95
IT3205 - Software Design
UCSC - 2014 96
IT3205 - Software Design
T1,T2 and T3 tests are carried out after integration of components A and B. If
the tests are successful, add C and carry out tests T1,T2,T3 and T4. If new
errors introduced, that is due to the integration of C.
UCSC - 2014 97
IT3205 - Software Design
UCSC - 2014 98
IT3205 - Software Design
UCSC - 2014 99
IT3205 - Software Design
Interface Testing
• Interface testing takes place when modules or subsystems
are integrated to create large systems.
• Each module or sub-system has a defined interface which is
called by other program components.
• Objectives are to detect faults due to interface errors or
invalid assumptions about interfaces.
• Particularly important for object-oriented development as
objects are defined by their interfaces.
• Cannot be detected by testing the individual objects.
– The errors will occur due to the interaction between objects.
Types of Interfaces
• Parameter Interfaces
– These are interfaces where the data or sometimes function references are
passed from one component to another.
• Shared memory Interfaces
– These are interfaces where block of memory is shared between sub-systems.
Data is placed in memory by one sub-system and retrieved from there by
other sub-system.
• Message passing Interfaces
– These are interfaces where one subsystem request a service from another
sub-system by passing a message to it.
• Procedural Interfaces
– These are interfaces where one sub-system encapsulates a set of procedures
which can be called by other subsystem. Objects and abstract data types
have this form of interface.
System Testing
• System testing is carried out at the completion
of the integration testing. The purpose of
system testing is to prove that the software
meets the agreed user requirements and
works in the target environment. System
Acceptance Testing
• Acceptance testing is carried out at the
customers site with the customer in
attendance. The purpose of the acceptance
test is to show to the customer that the
software does indeed work. These tests are
usually a sub set of the system test.
Thread testing
• Based on testing an operation which involves a
sequence of processing steps which thread their
way through the system
Object Integration
• In object oriented systems, there is no obvious
‘top’ that provides for the integration nor is there a
clear hierarchy of objects that can be created.
Object Integration
• There are three possible approaches to integration
testing that may be used:
1. Use-case or scenario-based testing – Testing can be based on
the scenario descriptions and object clusters created to support the
usecases that relate to that mode of use.
2. Thread testing – Thread testing is based on testing the
system’s response to a particular input or set of input events.
Quality Management
• Software quality management can be structured into three
principal activities:
1. Quality assurance
• The establishment of a framework of organizational procedures and
standards which lead to high quality software.
2. Quality planning
• The selection of appropriate procedures and standards from this
framework and adaptation of these for a specific software project.
3. Quality control
• The definition and enactment of processes which ensure that the project
quality procedures and standards are followed by the software
development team.
What is Quality?
• Quality, simplistically, means that a product should
meet its specification.
• This is problematical for software systems
What is Quality?
• Traditional view
• Quality planning
– Select applicable procedures and standards for a particular project
and modify these as required.
• Quality control
– Ensure that procedures and standards are followed by the software
development team.
Process-based Quality
6.7 STANDARDS
Importance of Standards
• Encapsulation of best practice
– avoids repetition of past mistakes.
ISO9000
• ISO9000 is a set of international standards that can be
applied to a range of organizations from manufacturing
through to service industries.
• ISO9001 is the most general of these standards and applies
to organizations concerned with quality processes regarding
design, development and maintain products. This is a generic
model of a quality process which describes various aspects of
that process and defines which standards and procedures
could exist within an organization.
• ISO 9000-3 interprets ISO 9000 for software development.
ISO9000
• ISO900-1 is a general guideline which gives background
information about the family of standards.
• ISO9002 and ISO9003 are subsets of ISO9001.
• ISO9002 is used for situations in which there is no design.
• ISO9003 is used for situations in which there is neither
design nor production (eg. Retail).
• ISO9000-3 is a guideline on how to use ISO9001 for
software development.
ISO9000
• When asked whether cost, timescale or quality was most important
when completing against another company for a software project Tomoo
Mastubara of Hitachi Software Engineering replied
“Quality is first! Always first. If we deliver bad quality to the customer,
the customer will complain many times, over and over. But if we are
late, he will complain only once and then may be he will forget. And if
we have underestimated the cost, the customer will not complain at
all. – for he will know we have made the mistake. WE will bear the
burden of the cost mistake”
• Any serious quality initiative will repay any set-up costs within the first
years through improved productivity and customer satisfaction.
Documentation Standards
• Documentation standards in a software project are
particularly important as documents are the only tangible
way of representing the software and the software
process.
2. Document Standards
• Govern the structure and presentation of documents.
Incorporate
Create initial Re-draft
Review draft review
UCSC - 2014 draft document 148
Comments
IT3205 - Software Design
Key Points
• Software quality management is concerned with
ensuring that software has a low number of
defects and that it reaches the required standards
of maintainability, reliability, portability and so on
• SQM includes defining standards for processes
and products and establishing processes to check
that these standards have been followed
Key Points
• Software standards are important for quality
assurance as they represent an identification of
‘best practice’
• Quality management procedures may be
documented in an organizational quality manual,
based on the generic model for a quality manual
suggested in the ISO 9001 standard