35
DEE 2112 Sem 1 09/10 CHAPTER 1 PRINCIPLE OF SOFTWARE DEVELOPMENT

Ch1 principles of software development

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Ch1 principles of software development

DEE 2112 Sem 1 09/10

CHAPTER 1

PRINCIPLE OF SOFTWARE DEVELOPMENT

Page 2: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Objectives

In this chapter you will learn:

The computer programming languageTo solve problem using problem-solving strategies

and methodsThe algorithm as a guidance in designing program

Page 3: Ch1 principles of software development

DEE 2112 Sem 1 09/10

SOFTWARE DEVELOPMENT PRICIPLE

SubtopicsIntroduction to ProgrammingProblem Solving & Software Development

ApproachAlgorithm Representation

Page 4: Ch1 principles of software development

DEE 2112 Sem 1 09/10

1.1 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.

Page 5: Ch1 principles of software development

DEE 2112 Sem 1 09/10

1.2 Problem Statement & SDA

Problem Solving 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.

Page 6: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Software Development Method

Requirements specification Analysis Design Coding & Implementation Testing & Verification Documentation & Maintenance

Page 7: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Software Development Method

Requirements specification provides us with a precise definition of the problem.

In the analysis phase, we identify problem inputs, outputs, special constraints, and formulas and equations to be used.

The design phase is concerned with developing an algorithm for the solution of the problem.

Page 8: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Software Development Method

Coding & ImplementationCode the finalized algorithm using a suitable

programming language.Go through the compiling & execution process.Normally, you will face this three types of

programming errorsLogic/Design errors Syntax errorsRuntime errors

Page 9: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Logic/Design errorso 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.

Page 10: Ch1 principles of software development

DEE 2112 Sem 1 09/10

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.

Page 11: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Runtime Errorso 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.

Page 12: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Software Development Method

Documentation & MaintenanceFor 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.

Page 13: Ch1 principles of software development

DEE 2112 Sem 1 09/10

1.3 Algorithm Representation 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

Page 14: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Analogy

A) How to make a telephone call ?i. ?

ii) ? iii) ? B) How to make a fried rice ? C) How to buy a tin of pepsi-cola from vending machine ?

Page 15: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Pseudocoding

Short English phrases with a limited vocabularyare 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

Page 16: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Example of Pseudocode

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

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

Page 17: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Flowcharting

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

Page 18: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Flowchart SymbolsSymbol 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

Page 19: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Flowchart SymbolsSymbol 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

Page 20: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Example of Flowchart

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

Page 21: Ch1 principles of software development

DEE 2112 Sem 1 09/10

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

o Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied.

Page 22: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Sequence Structure

begin

Statement_1

Statement_2

Statement_n

end

Statement_1

Statement_2

Statement_n

Page 23: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Selection Structure• Single Selection (if)

if condition

statement

if condition

then_part

else

else_part

end_if

• Double Selection (if-else)

condition

if_partelse_part

YesNo

statementcondition

Page 24: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Repetition Structure

while condition

loop-body

end_while condition Loop_bodyYes

Page 25: Ch1 principles of software development

DEE 2112 Sem 1 09/10

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

Page 26: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Applying the SDM

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 : test_score >= 50 test_score < 50 Constrain : the test score must greater than 0 (zero)

Page 27: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Applying the SDM

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

Page 28: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Applying the SDM

Flowchart

Page 29: Ch1 principles of software development

DEE 2112 Sem 1 09/10

Exercise

1. Write an algorithm that calculates the areas of a football field.

2. Write an algorithm that finds the smallest element among a, b, and c.

Page 30: Ch1 principles of software development
Page 31: Ch1 principles of software development
Page 32: Ch1 principles of software development
Page 33: Ch1 principles of software development
Page 34: Ch1 principles of software development
Page 35: Ch1 principles of software development