Вы находитесь на странице: 1из 17

CHAPTER 1

SOFTWARE
DEVELOPMENT
METHOD

BEC 10102 SEM 1 2010/2011 1

Objectives
In this chapter you will learn:
™The electronic computers and its’
suitable programming language
™To solve problem using problem-solving
strategies and methods
™The algorithm as a guidance in
designing program

BEC 10102 SEM 1 2010/2011 2

1
Subtopics

‰Electronic Computers
‰Introduction to Programming
‰Software Development Method
(SDM)
‰Algorithm Design

BEC 10102 SEM 1 2010/2011 3

Electronic Computers
What is computer ?
ƒ A computer is an electronic device
designed to perform operations specified
with a set of instructions called a program.
ƒ A computer include both hardware &
software

BEC 10102 SEM 1 2010/2011 4

2
Why we need computers ?
The use of Computer in daily activities
™ bill payment, booking transportation ticket,
communication services, e-mailing friends, on-line
communication, subject registration, course
assessments & etc.

As for engineering students, you should develop


the ability to solve problems, and it is very likely
that you will need to use computers for problem
solving

BEC 10102 SEM 1 2010/2011 5

Computer Hardware (1)


Major hardware components :

™ Central Processing Unit (CPU)


ƒ Control unit (CU) & Arithmetic/Logic Unit (ALU)
™ Memory (main memory)
™ Storage Devices (disks, CDs, tapes)
™ Input/Output Devices (monitors, keyboards, mice, printers
™ Communication Devices (modems and network interface
cards (NIC cards)

Note : The components are connected through a subsystem called a


bus that transfers data between the components.
(Source : Y.D. Liang “Introduction to Programming with C++”, Comprehensive
Version. International Edition. Pearson Education, 2007)

BEC 10102 SEM 1 2010/2011 6

3
Computer Hardware (2)
HARDWARE = PERIPHERAL EQUIPMENT + CENTRAL/SYSTEM UNIT

BEC 10102 SEM 1 2010/2011 7

Computer Software
™Operating System (OS)
™Unix, Window, Linux

™Software Tools (Utility Packages)


o word processors (MicrosoftWord, WordPerfect)
o spreadsheet programs (Excel, Lotus1-2-3, ...)

™Computer Languages/ Programming Languages


o machine language
o assembly language
o binary language
o high level languages (C, C++, Ada, Fortran,
Basic, java)

™ User Developed Programs


o SMAP On-Line
o MayBank2you
BEC 10102 SEM 1 2010/2011 8

4
Intro to Programming
Programming is the core of everything to do with
computers, computing, networked systems,
management information systems, multimedia and
so on (all computer-based things)

Everything that runs on a computer is a program


and somebody (programmer) has to write it using
specific programming language. To understand
how computers can be used, how applications
work, how systems are configured, it is necessary for
you to understand what programs are and how
they are constructed.

BEC 10102 SEM 1 2010/2011 9

Software Development Method


(SDM)
What is Problem Solving@Solution ?

The process of transforming the description


of a problem into the solution of that
problem by using our knowledge of the
problem domain and by relying on our
ability to select and use appropriate
problem-solving strategies, techniques, and
tools.

BEC 10102 SEM 1 2010/2011 10

5
SDM Phases
™provides us with a precise definition of the
problem.

™ we identify problem inputs, outputs, constraints,


and formulas and equations to be used.

™concerned with developing an


algorithm (subtopic 1.4) for the solution
of the problem.

BEC 10102 SEM 1 2010/2011 11

SDM : Coding & Implementation

™Code the finalized algorithm using a suitable


programming language.
™Go through the compiling & execution
process.
™Normally, you will face this three types of
programming errors
™Logic/Design errors
™Syntax errors
™Runtime errors

BEC 10102 SEM 1 2010/2011 12

6
Logic/Design errors

o Design errors occur during the analysis, design,


and implementation phases.
o We may choose an incorrect method of solution
for the problem to be solved, we may make
mistakes in translating an algorithm into a
program, or we may design erroneous data for
the program.
o Design errors are usually difficult to detect.
o Debugging them requires careful review of
problem analysis, algorithm design, translation,
and test data.

BEC 10102 SEM 1 2010/2011 13

Syntax Errors
o Syntax errors are violations of syntax rules, which
define how the elements of a programming
language must be written.
o They occur during the implementation phase
and are detected by the compiler during the
compilation process. In fact, another name for
syntax errors is compilation errors.
o If your program contains violations of syntax rules,
the compiler issues diagnostic messages.
o Depending on how serious the violation is, the
diagnostic message may be a warning message
or an error message.

BEC 10102 SEM 1 2010/2011 14

7
Runtime Errors

o Run-time errors are detected by the computer


while your program is being executed.
o They are caused by program instructions that
require the computer to do something illegal,
such as attempting to store inappropriate data
or divide a number by zero.
o When a run-time error is encountered, the
computer produces an error diagnostic message
and terminates the program execution.
o You can use diagnostic messages to debug run-
time errors.

BEC 10102 SEM 1 2010/2011 15

SDM : Testing and Verification

• Testing the completed program to verify that it


works as desired.
• Do not rely on just one test case .
• Run the program several times using different
sets of data to make sure that it works correctly
for every situation provided in the algorithm.

BEC 10102 SEM 1 2010/2011 16

8
SDM : Documentation & Maintenance
For every problem solving, there are 5 things to be
documented :
™ Program description
™ Algorithm development and changes
™ Well-commented program listing
™ Sample test run
™ User’s manual

Maintenance is concerned with ongoing correction


of problems, revision to meet changing needs and
addition of new features. The better the documentation
is, the efficiently this phase can be performed.

BEC 10102 SEM 1 2010/2011 17

Algorithm Design
™ An algorithm is a sequence of a finite
number of steps arranged in a specific
logical order that, when executed,
produces the solution for a problem.

™ An algorithm design should be put on


paper. For this purpose, and also to
facilitate its development, we resort to
pseudocoding and flowcharting

BEC 10102 SEM 1 2010/2011 18

9
Analogy

A) How to use ATM Machine ?


i. Step 1 ?
ii. Step 2 ?
……….
x. Final step ?

B) How to register courses using SMAP


on-line ?

BEC 10102 SEM 1 2010/2011 19

Pseudocoding
Short English phrases with a limited
vocabulary are use to describe the
algorithm (the processing steps). A
pseudocode must :

™ have a limited vocabulary


™ be easy to learn
™ produce simple, English-like narrative notation
™ be capable of describing all algorithms,
regardless of their complexity

BEC 10102 SEM 1 2010/2011 20

10
Example of Pseudocode

Problem 1 : (Sequence structure)


Compute total of resistor values.
Begin
read resistor1, resistor2
total = resistor1 + resistor2
print “ total “
End

BEC 10102 SEM 1 2010/2011 21

Flowcharting

A graphical technique for algorithm


design and representation, is
equivalent to pseudocoding and
can be used as an alternative to it.

BEC 10102 SEM 1 2010/2011 22

11
Flowchart Symbols (1)
Symbol Name Of Symbol Description And
Example
Indicates the
Terminal beginning or end of
an algorithm
Indicates an Input
Input/Output or Output operation
Indicates
Process computation or data
manipulation
Indicates a decision
Decision point in the
algorithm

BEC 10102 SEM 1 2010/2011 23

Flowchart Symbols (2)


Symbol Name Of Symbol Description And
Example
Specific for for
statement
Loop Indicates the initial, final
and increment values of a
loop.
Used to connect the
Flow Lines/ Arrow symbols and indicates the
logic flow
Provides continuation of a
On-Page Connector logical path on another
point in the same page.
Provides continuation of a
Off-Page Connector logical path on another
page

BEC 10102 SEM 1 2010/2011 24

12
Example of Flowchart

Problem 1 : (Sequence statements)


Compute total of resistor
values.

BEC 10102 SEM 1 2010/2011 25

Pseudocode & Flowchart Convention

™Sequence Structure
o a series of steps or statements that are
executed in order (ex : as shown in Problem 1)
™Selection Structure
o Define two courses of action depending on
the outcome condition ( true or false)
™Repetition control structures
oSpecifies a block of one or more statements
that are repeatedly executed until a condition
is satisfied.

BEC 10102 SEM 1 2010/2011 26

13
Sequence Structure

begin
Statement_1 Statement_1

Statement_2
Statement_2

Statement_n
end Statement_n

BEC 10102 SEM 1 2010/2011 27

Selection Structure

• Single Selection (if)


condition Yes statement
if condition
statement No

• Double Selection (if-else)

if condition
condition yes then_part
then_part
else no

else_part
else_part

end_if

BEC 10102 SEM 1 2010/2011 28

14
Repetition Structure

while condition
loop-body
condition Yes Loop_body

end_while

No

BEC 10102 SEM 1 2010/2011 29

Applying the SDM ( Phase 1 to 3)

Problem :
The C programming test scores can
be classified into two condition, PASS
and FAIL. The student is require to
input their marks in positive integer . If
the score is greater than or equal 50
message Pass will appear, message
Fail otherwise

BEC 10102 SEM 1 2010/2011 30

15
Applying the SDM : Phase 1 & 2
Phase 1 : Requirement Specification
™ Selection Structure
™ test scores, message ‘PASS’, message ‘FAIL’, greater or
equal to 50, less than 50

Phase 2 :
Data requirements :
Input : test_score
Output : ‘PASS’ or ‘FAIL’
Relevant formula : None
Constrain : the test score must greater than 0
(zero)
Condition : test_score >= 50
test_score < 50

BEC 10102 SEM 1 2010/2011 31

Applying the SDM : Phase 3 (1)

Phase 3 : Design ( Pseudocode/Flowchart)


™ Pseudocode
Begin
Read the test scores
Begin while
while test_score < 0
Print ‘ Re-enter your score and must greater than 0’
Read the test_score
End while
if test_score >= 50
print ‘PASS’
else
print ‘FAIL’
End

BEC 10102 SEM 1 2010/2011 32

16
Applying the SDM : Phase 3 (2)
™ Flowchart

BEC 10102 SEM 1 2010/2011 33

Exercises
1. Write an algorithm that calculate
the multiplication of two integer
numbers.
2. Write an algorithm which can
determine the positive and
negative integer.
3. Write an algorithm that can print
series of odd numbers between 0
and 12.

BEC 10102 SEM 1 2010/2011 34

17

Вам также может понравиться