chapter 2

39
1 CHAPTER 2 SOFTWARE DEVELOPMENT METHOD

Upload: preston-blanchard

Post on 02-Jan-2016

19 views

Category:

Documents


0 download

DESCRIPTION

CHAPTER 2. SOFTWARE DEVELOPMENT METHOD. 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. Subtopics. - PowerPoint PPT Presentation

TRANSCRIPT

1

CHAPTER 2SOFTWARE

DEVELOPMENT METHOD

2

Objectives

In this chapter you will learn:The electronic computers and its’

suitable programming languageTo solve problem using problem-

solving strategies and methodsThe algorithm as a guidance in

designing program

3

Subtopics

Electronic ComputersIntroduction to ProgrammingSoftware Development

Method (SDM)Algorithm Design

4

Electronic ComputersWhat 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

5

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

6BEC 10102 SEM 1 2010/2011

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)

7BEC 10102 SEM 1 2010/2011

Computer Hardware (2)

HARDWARE = PERIPHERAL EQUIPMENT + CENTRAL/SYSTEM UNIT

8

Computer SoftwareOperating System (OS)

Unix, Window, Linux

Software Tools (Utility Packages)oword processors (MicrosoftWord,

WordPerfect)ospreadsheet programs (Excel, Lotus1-

2-3, ...)

Computer Languages/ Programming Languages

omachine languageoassembly languageobinary languageohigh level languages (C, C++, Ada,

Fortran, Basic, java)

User Developed ProgramsoSMAP On-LineoMayBank2you

9BEC 10102 SEM 1 2010/2011

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.

10

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.

11

SDM PhasesRequirement Specification

Analysis

Design

Testing & Verification

Coding & Implementation

Documentation & Maintenance

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.

12

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 errorsRuntime errors

13

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.

14

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.

15

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.

16BEC 10102 SEM 1 2010/2011

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.

17

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.

18

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

19

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 ?

20

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

21

Example of Pseudocode

Problem 1 : (Sequence structure) Compute total of resistor values.

Begin read resistor1, resistor2 total = resistor1 + resistor2 print “ total “ End

22

Flowcharting

A graphical technique for algorithm design and representation, is equivalent to pseudocoding and can be used as an alternative to it.

23

Flowchart Symbols (1)Symbol Name Of Symbol Description And

Example

TerminalIndicates the beginning or end of an algorithm

Input/OutputIndicates an Input or Output operation

ProcessIndicates computation or data manipulation

DecisionIndicates a decision point in the algorithm

24

Flowchart Symbols (2)Symbol Name Of Symbol Description And

Example

Loop

Specific for for statementIndicates the initial, final and increment values of a loop.

Flow Lines/ ArrowUsed to connect the symbols and indicates the logic flow

On-Page Connector Provides continuation of a logical path on another point in the same page.

Off-Page ConnectorProvides continuation of a logical path on another page

25

Example of Flowchart

Problem 1 : (Sequence statements) Compute total of resistor values.

26

Pseudocode & Flowchart Convention

Sequence Structureo 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.

27

Sequence Structure

begin

Statement_1

Statement_2

Statement_n

end

Statement_1

Statement_2

Statement_n

28BEC 10102 SEM 1 2010/2011

Selection Structure

• Single Selection (if)

if condition

statement

if condition

then_part

else

else_part

end_if

• Double Selection (if-else)

condition statement

No

Yes

condition then_part

else_part

no

yes

29BEC 10102 SEM 1 2010/2011

Repetition Structure

while condition

loop-body

end_whilecondition Loop_body

No

Yes

30

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

31

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

32BEC 10102 SEM 1 2010/2011

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

33BEC 10102 SEM 1 2010/2011

Applying the SDM : Phase 3 (2)

Flowchart

34

Exercises1. Write an algorithm (Pseudo code

and flow chart) for attending a lecture

2. Write an algorithm that calculate the multiplication of two integer numbers.

3. Write an algorithm which can determine the positive and negative integer.

4. Write an algorithm that can print series of odd numbers between 0 and 12.

35

Start

Wake Up

Take Shower

Get Dressed

Eat Breakfast

Has Transport

Take Transport

Walk to Lecture hall

Late?

Enter Class

Go back home

End

Y

N

Y

N

36

Begin

Wake up

Take shower

Get dressed

Eat breakfast

If has transport

take transport

Else

walk to lecture hall

If late

go back home

Else

enter class

end

37

Begin

int w;

int l;

int area;

w=20;

l=25;

area=w*l

print “Your area is “

print area

end

38

–Write a program to calculate the square area. Print area

–Design a Program that a salesperson gets 6 percent commission on sales less than $1000, 8 percent on sales in the range $1000 through $2000, and 10 percent on sales in excess of $2000. Print the commission.

39

• Write a program that can read age. Print “young” if the age less than 20, print “Adult” if the age between 20 to 30 and print “old” if the age above 30.