Session 05

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

DCIT 104

Programming Fundamentals

Session 5 - Program Design and


Specification
Lecturer: Mr. Joseph Ecklu (DCS)
Contact Information: jecklu@ug.edu.gh

College of Education
School of Continuing and Distance Education
2014/2015 – 2016/2017
Session Overview
• INTRODUCTION
In this session we consider the important issue of
program design – the third stage in the Program
Development Framework. The basic knowledge of
program design needed to write programs of
reasonable quality will be discussed.

Mr. Joseph Ecklu (DCS) Slide 2


Session Objectives
After studying the session the student should be able to
- Use the results of the analysis stage i.e. program
specification to do design
- Know the aims of the design stage
- Ensure program specification and its correctness
- Describe the program development stages
- Explain the concepts that lie behind program design
- List the tools required for good design

Mr. Joseph Ecklu (DCS) Slide 3


Reading List
• REFERENCES
1. C.S. FRENCH, COMPUTER SCIENCE (2000) chpt 18
2. Eric Grimson and John Guttag, 6.00 Introduction to Computer
Science and Programming, Fall 2008. (Massachusetts
Institute of Technology: MIT OpenCourseWare).
http://ocw.mit.edu (accessed 01 28, 2015). License: Creative
Commons Attribution-Noncommercial-Share Alike.
3. Jesse Dunietz, Geza Kovacs, and John Marrero. 6.096
Introduction to C++, January IAP 2011. (Massachusetts
Institute of Technology: MIT OpenCourseWare),
http://ocw.mit.edu (Accessed 28 Jan, 2015). License:
Creative Commons BY-NC-SA
Mr. Joseph Ecklu (DCS) Slide 4
PROGRAM DESIGN AND SPECIFICATION

• Goals

Mr. Joseph Ecklu (DCS) Slide 5


PROGRAM DESIGN AND SPECIFICATION

• TOPICS
• The importance of good programming methods
• Program Design
• Program specification and correctness
• Methods for program development
• Program Development Framework/ Stages in
programming
• Program Design Concepts

Mr. Joseph Ecklu (DCS) Slide 6


PROGRAM DESIGN AND SPECIFICATION

Mr. Joseph Ecklu (DCS) Slide 7


Good Programming Methods
• Importance of Good Programming Methods
Reasons that greater efforts should be put into program
design include the following :-

1. Great reliance placed upon computers for all


applications – military, banking, health

2. High cost of programming labour

3. Need for good-quality programming is greater than ever


Mr. Joseph Ecklu (DCS) Slide 8
PROGRAM DESIGN AND SPECIFICATION

Mr. Joseph Ecklu (DCS) Slide 9


PROGRAM DESIGN AND SPECIFICATION

• Aims of Program Design


– Reliability : the program can be depended upon always to do
what it is supposed to do
– Maintainability: the program will be easy to change or modify
when the need arises
– Portability: the program will be transferable to a different
computer with a minimum of modification
– Readability: the program will be easy for a programmer to
read and understand
– Performance: the program causes the tasks to be done quickly and
efficiently
– Storage Saving: the program is not allowed to be unnecessarily
long
Mr. Joseph Ecklu (DCS) Slide 10
Mr. Joseph Ecklu (DCS) Slide 11
Program specification and correctness

• Program specification gives a specification of what


the proposed program is required to do
• A program that meets its specification is said to be
‘correct’
• Where the specification is wrong, this could lead to
program being ‘correct’ but ‘unsuitable’
• The specification may be right, it may be very difficult
to ensure that the program is correct

Mr. Joseph Ecklu (DCS) Slide 12


Program specification and correctness

• Good programming Methods are required to ensure


that the programmer
– produces correct programs from specifications that truly
express the requirements
– Correct programs must be
• Reliable
• Maintainable
• Portable
• Readable
• efficient

Mr. Joseph Ecklu (DCS) Slide 13


Methods for Program Development
• Program Development Framework
Stages:
1. Problem Definition: as defined by System Specification
2. Analysis : Understanding the problem ,defining the method of
solution
3. Design : developing the methods using suitable aids
4. Coding : typing the instructions into the computer using a
programming language
5. Testing and debugging: testing the program and removing
errors
6. Documentation: writing all the work involved in producing the
program
Mr. Joseph Ecklu (DCS) Slide 14
Program Development Framework
Analysis

Mr. Joseph Ecklu (DCS) Slide 15


Program Development Framework
• Analysis

The programmer need to know exactly


- what the program is required to do and normally
works from a program specification
- The program specification is normally part of a
System Specification
- The System Specification defines the whole system
of which the program may be a small part

Mr. Joseph Ecklu (DCS) Slide 16


Program Development Framework
• Analysis
The program specification must be well defined
- Input specification
- Process specification
- Output specification
- Limitations of the program
- A good specification will specify what processing is
needed by giving the exact relationship between
outputs and the inputs from which they are derived

Mr. Joseph Ecklu (DCS) Slide 17


Program Development Framework
• Analysis
- A good specification will specify
- what processing is needed by giving the exact relationship
between outputs and the inputs from which they are
derived
- Rather than prescribing how the program should be
written

Mr. Joseph Ecklu (DCS) Slide 18


Program Development Framework
• Analysis
- Plan the method of solution
- Determine the extent of the task
- For large programs share the programming effort among
many programmers
- Modules/segments are the separate parts
- Modules are prepared and tested separately
- Integration : Modules are linked together and tested as a
whole

Mr. Joseph Ecklu (DCS) Slide 19


Program Development Framework
• Design
Tools for design include the following
- Top-down design
- Algorithms
- Flowchart
- Pseudo-codes
(details later )

Mr. Joseph Ecklu (DCS) Slide 20


Program Development Framework
• Coding
The last step in Top-down design
- The instructions written in pseudo-codes or flowcharts
are written in a programming language
- There are different types of programming languages as
discussed under classification of programming languages
- In this course, imperative / structured/ procedural
language will be used
- C++ is the language for practising the programming
concepts
Mr. Joseph Ecklu (DCS) Slide 21
Program Development Framework
• Testing and debugging the Program
Programs once written / coded has to be
- Tested: checked that it has been written out and
transcribed correctly
- that it does what it is suppose to do i.e. correct
- debugged: tests may reveal errors which have to be
corrected

Mr. Joseph Ecklu (DCS) Slide 22


Program Development Framework
• Testing and debugging the Program
Stages of testing
- Unit testing: testing the separate components
- Integration testing: testing the separate components
as they are put together
- System testing: testing the whole program once it is
in its final form in which it will be used
- User acceptance testing: the user of the program
(possibly the customer) testing the program to see
that it is what is required
Mr. Joseph Ecklu (DCS) Slide 23
Program Development Framework
• Documentation
Very important that the work of the programmer in
producing a finished program is fully documented
Documents include
- Statement of the problem/system specification
- Pseudo-codes
- Codes
- Test data and results

Mr. Joseph Ecklu (DCS) Slide 24


Program Development Framework
• Documentation
Note:
- Producing these documents should be done as part
of each stage in programming and not as an
afterthought
- Good documentation aids maintenance of the
program during its lifetime

Mr. Joseph Ecklu (DCS) Slide 25


PROGRAM DESIGN CONCEPTS
• Concepts relevant to the general problems of
Program Design
- Computability
- Complexity
- Correctness

Mr. Joseph Ecklu (DCS) Slide 26


PROGRAM DESIGN CONCEPTS

• Computability
In programming our concern is
- What tasks computers can do and how they do them
- Undesirables : There are problems that computers can
not solve e.g. Tasks that for practical reasons , tasks
that can be proven to be theoretically impossible, ‘the
halting problem’
- Computable : tasks that in principle can be performed
by a machine
Mr. Joseph Ecklu (DCS) Slide 27
PROGRAM DESIGN CONCEPTS
• Complexity
In programming complexity is measured in terms
of the quantity of resources used
- Time : taken to perform the task
- storage : requirements
Algorithm : for many tasks there may exist many
alternative algorithms and for practical reasons a
knowledge of their complexity will help us make
the best choice
Mr. Joseph Ecklu (DCS) Slide 28
PROGRAM DESIGN CONCEPTS
• Correctness
A program is correct if it meets its
specification

To prove that a program is correct


- Show that for all permissible input to the
program the program will produce the
required results
Mr. Joseph Ecklu (DCS) Slide 29
PROGRAM DESIGN CONCEPTS
• Correctness
Test data
A set of carefully selected data used in testing the
program

Testing may be done


- By executing the program on the computer
- ‘dry run’ = simulating program execution by a
manual pencil and paper exercise
Mr. Joseph Ecklu (DCS) Slide 30
PROGRAM DESIGN CONCEPTS
• Correctness
2 basic types of testing
- Functional Testing
- Logical testing

Mr. Joseph Ecklu (DCS) Slide 31


PROGRAM DESIGN CONCEPTS
• Functional / blackbox testing
- Based upon typical, extreme and invalid data
values that are representative of those covered
by the specification
- Used at the final stage of programming as a basis
for accepting or rejecting the program
- Not adequate by itself, logical testing by the
programmer during program development tends
to be more beneficial
Mr. Joseph Ecklu (DCS) Slide 32
PROGRAM DESIGN CONCEPTS
• Logical testing / white box
testing
- Based upon examining the internal
structure of the program and
selecting data which give rise to the
alternative cases of control flow e.g.
both paths through an if…then…else
Mr. Joseph Ecklu (DCS) Slide 33
PROGRAM DESIGN CONCEPTS
• bug
A program fault that causes a program to
fail during testing, or after it has been
commissioned
• Debugging
The process of finding and getting rid
of bugs
Mr. Joseph Ecklu (DCS) Slide 34
PROGRAM DESIGN CONCEPTS
• Trouble shooting bugs
- Bugs are often the result of poor workmanship on
the part of
- Persons who produced the program specification or
- Persons who wrote the program
- Reasons for the occurrence of bugs must be
investigated fully and that
- Program’s design and implementation are reworked
where necessary

Mr. Joseph Ecklu (DCS) Slide 35


Session Summary
It is importance the go through a systematic approach
in designing a program to yield the desired
functionality of the program. This stages for program
design and specifications are
- Analysis
- Design
- Coding
- Testing and debugging
- Documentations

Mr. Joseph Ecklu (DCS) Slide 36


PROGRAM DESIGN CONCEPTS
• Correctness
A program is correct if it meets its
specification

Mr. Joseph Ecklu (DCS) Slide 37


Trial Question
1. List and explain the various stages of testing
2. What is the importance of documentation
3. List in order the stages of program development
4. Explain briefly each stage specified in 2. above
5. What are the importance of good programming
methods

Mr. Joseph Ecklu (DCS) Slide 38

You might also like