Steps to program development

Similar documents
1. Introduction to Programming

102 Dodds Street Southbank Victoria Website:

Chapter 1 Program Design

FLOW CHART AND PSEUDO CODE

SNS COLLEGE OF ENGINEERING,

Computer System and programming in C

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

UNIT - 1 COMPUTER BASICS INTRODUCTION TO C

FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING UNIT III. 2 Marks PROBLEM SOLVING AND OFFICE AUTOMATION

Problem Solving and Algorithms

Chapter Twelve. Systems Design and Development

Lesson 1. Introduction to Programming OBJECTIVES

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

Programming Logic - Beginning

S/W Programming & Languages

Outline. Program development cycle. Algorithms development and representation. Examples.

Algorithms, Part 2 of 3. Problem Solving. Problem Solving (con t) Topics Problem Solving Examples Pseudocode Control Structures

SNS COLLEGE OF ENGINEERING

Algorithms, Part 2 of 3. Topics Problem Solving Examples Pseudocode Control Structures

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING

Homework #2. If (your ID number s last two digits % 6) = 0: 6, 12, 18

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Fourth Edition

Python - Week 1. Mohammad Shokoohi-Yekta

1. The first step that programmers follow when they solve problems is to plan the algorithm.

Chapter 1: An Overview of Computers and Logic

Scheme of work Cambridge International AS & A Level Computing (9691)

Chapter Two: Program Design Process and Logic

Algorithms. Abdelghani Bellaachia, CSCI 1121 Page: 1

Programming Logic Beginning

Chapter 3 Structured Program Development

Structured Program Development in C

Pseudo Code and Flow Charts. Chapter 1 Lesson 2

Copyright 2005 Department of Computer & Information Science

PROBLEM SOLVING AND OFFICE AUTOMATION. A Program consists of a series of instruction that a computer processes to perform the required operation.

Chapter 1 - An Introduction to Computers and Problem Solving

9/23/2013. Chapter 2. Objectives. Introduction. Objectives (continued) Representing Algorithms. Representing Algorithms

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

Method & Tools for Program Analysis & Design

III. Check if the divisors add up to the number. Now we may consider each of these tasks separately, assuming the others will be taken care of

Constructing Algorithms and Pseudocoding This document was originally developed by Professor John P. Russo

Unit II. (i) Computer Programming Languages

INTRODUCTION TO ALGORITHMS

At the top of the every document that you create (word processing or source files) include:

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

Top Down Design. 2. Design Methodology

FLOWCHARTS A flowchart is a graphical representation of the steps to be followed for solving problem. It consists of a set of symbols.

Understanding the problem

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Chapter 3 Developing a Program

Introduction Objectives: 1) differentiate between high-level, low-level, and machine language; 2) explain why it is necessary to translate a program

A Beginner s Guide to Programming Logic, Introductory. Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs

Algorithms. Chapter 8. Objectives After studying this chapter, students should be able to:

Introduction to Computer Programming/Handout 01 Page 1 of 13

Chapter 2 - Control Structures

SOEE1160: Computers and Programming in Geosciences Semester /08. Dr. Sebastian Rost

Introduction to Programming

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042

ITEC102 INFORMATION TECHNOLOGIES

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

CSC 121 Spring 2017 Howard Rosenthal

8 Algorithms 8.1. Foundations of Computer Science Cengage Learning


A Quick Review of Chapter 1

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Chapter 1 Lab Algorithms, Errors, and Testing

Developing Algorithms

Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs

BIL101E: Introduction to Computers and Information systems Lecture 8

Module 1: Introduction to Computers, Programs, and Java

Computing and compilers

Lab 2: Structured Program Development in C

Programming revision. Revision tip: Focus on the things you find difficult first.

More about Loops and Decisions

Chapter 4: Writing and Designing a Complete Program. Programming Logic and Design, Third Edition Introductory

1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100?

Variable A variable is a value that can change during the execution of a program.

Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today.

depicts pictorially schematic representation of an algorithm document algorithms. used in designing or documenting

IS 0020 Program Design and Software Tools

Chapter Five: Functions

An Introduction to Computer Problem Solving and the Programming Process

Chapter 2 - Problem Solving

Lecture 1: Preliminaries

How to approach a computational problem

Discussion on Writing of Recursive Algorithm

PROBLEM SOLVING AND PYTHON PROGRAMMING

Updated: 2/14/2017 Page 1 of 6

Lecture_Module3 Prof Saroj Kaushik, IIT Delhi

Guidelines for Writing Mathematical Proofs

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

[Page 177 (continued)] a. if ( age >= 65 ); cout << "Age is greater than or equal to 65" << endl; else cout << "Age is less than 65 << endl";

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements

Chapter 2 - Control Structures

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Previously. Iteration. Date and time structures. Modularisation.

Transcription:

Automate processes - Programming Concepts and Design Steps to program development A computer program is a set of formal instructions, which the computer executes in order to carry out some designated task. Whether that task is as simple as adding two numbers together or as complex as maintaining a large inventory for a multi-national corporation, there is a common element involved. They are both achieved by the computer executing a series of instructions the computer program. The principles behind the examples given above are the same, but the inventory program would be far more lengthy and complex. It would involve millions of instructions for the computer to follow, while adding two numbers would involve only a few. Programming can be defined as the development of a solution to an identified problem. There are seven basic steps in the development of a program: 1. Define the problem This step (often overlooked) involves the careful reading and re-reading of the problem until the programmer understands completely what is required. 2. Outline the solution (analysis) Once the problem has been defined, the programmer may decide to break the problem up into smaller tasks or steps, and several solutions may be considered. The solution outline often takes the shape of a hierarchy or structure chart. 3. Develop the outline into an algorithm (design) Using the solution outline developed in step 2, the programmer then expands this into a set of precise steps (algorithm) that describe exactly the tasks to be performed and the order in which they are to be carried out. This step can use both structured programming techniques and pseudocode (covered in more detail later). 4. Test the algorithm for correctness (desk check) This step is one of the most important in the development of a program as is often forgotten. Test data needs to be walked though each step in the algorithm to check that the instructions described in the algorithm will actually do what they are supposed to. If logic errors are discovered then they can be easily corrected. 5. Code the algorithm into a specific programming language (coding) It is only after all design considerations have been met that a programmer should actually start to code the program. In preceding analysis it may have been necessary to consider which language should be used, as each has its own peculiarities (advantages and disadvantages). 6. Run the program on the computer (testing) This step uses a program compiler and test data to test the code for both syntax and logic errors. If the program is well designed then the usual time-wasting frustration and despair often associated with program testing are reduced to a minimum. This step will often need to be done several times until the programmer is satisfied that the program is running as required. FILE=Programming Concepts and Design.doc by Greg Tisdell Updated on 23 March 2009 1

7. Document and maintain the program (documentation) Program documentation should not be just listed as the last step in the development process, as it is an ongoing task from the initial definition of the problem to the final test results. Documentation also involves maintenance - the changes that are made to a program, often by another programmer, during the life of that program. The better a program has been documented and the logic understood, the easier it is for another to make changes. The whole process of defining problems to providing the coded solution are an ongoing process that is circular in nature and can be called the System Development Life Cycle (SDLC). Structured Programming Structured programming assists the programmer to write effective error-free programs. This term refers to a structured approach to program design using techniques such as Top-down development and Modular design. Top-down development Traditionally a programmer when presented with a problem would start coding at the beginning and work systematically though each step until reaching the end. Often the programmer would get bogged down in the intricacies of a particular part of the problem, rather than considering the solution as a whole. In top-down development of a program design, a general solution to the problem is outlined first. This is then broken down gradually into more detailed steps until finally the most detailed levels have been completed. It is only after this process of stepwise refinement that the programmer starts to code. The result of this systematic disciplined approach to program design is higher precision programming. Modular design Modular design involves grouping tasks together because they all perform the same function e.g. the calculation of sales tax, or the printing of report headings. Modular design is connected directly to top-down development, as the steps or subtasks which the programmer breaks up the program solution into, will actually format the future modules of the program. Good modular design also aids in the reading and understanding of the program. The Structure Theorem The Structure Theorem revolutionised program design by establishing a structured framework for representing the solution. The Theorem states that it is possible to write any computer program by using only three basic control structures. These control structures are: 1. Sequence 2. Selection, or IF-ELSE 3. Repetition, or WHILE, DO WHILE, FOR LOOP FILE=Programming Concepts and Design.doc by Greg Tisdell Updated on 23 March 2009 2

Algorithms and Pseudocode What is an algorithm? An algorithm is like a recipe. It lists the steps involved in accomplishing a task. It can be defined in programming terms as a set of detailed, unambiguous and ordered instructions developed to describe the processes necessary to produce the desired output from the given input. The algorithm is written in simple English and is not a formalised procedure, however to be useful there are some principles which should be adhered to. An algorithm must: 1. be lucid, precise and unambiguous 2. give the correct solution in all cases and 3. eventually end. For example, if you want to instruct someone to add up a list of prices on a pocket calculator, you might write an algorithm like the following: Turn on calculator Clear calculator Repeat the following instructions Key in dollar amount Key in decimal point (.) Key in cents amount Press plus (+) key Until all prices have been entered Press equal (=) key Write down total price Turn off calculator Notice that in this algorithm the first two steps are performed once, before the repetitive process of entering the prices. After all the prices have been entered and summed, the solution is obtained by pressing the equal key and writing down the total price. These final two activities and the turning off of the calculator are also performed only once. This algorithm lists all the steps in order from top to bottom, in a definite and unambiguous fashion until a correct solution is reached. Notice that the steps to be repeated, the entering and summing of the prices, are indented both to separate them from those steps performed only one and to emphasize the repetitive nature of their action. It is important to use indentation when writing solution algorithms. What is pseudocode? Traditionally flowcharts were used to represent the steps in an algorithm diagrammatically. However that method is bulky, difficult to draw and often led to poor program structure. In contrast, pseudocode is easy to read and write, as it represents the statements of an algorithm in English. Pseudocode is really structured English. It is English which has been formalised and abbreviated to look very like a high-level computer language. FILE=Programming Concepts and Design.doc by Greg Tisdell Updated on 23 March 2009 3

There is currently no standard pseudocode. Different textbook authors seem to adopt their own special techniques and set of rules, which often resemble a particular programming language. But as a guideline, try the following conventions: 1. Statements are written in simple English 2. Each instruction is written on a separate line 3. Keywords and indentation are used to signify particular control structures 4. Each set of instructions is written from top to bottom with only one entry and one exit 5. Groups of statements may be formed into modules and that group given a name If a programmer uses words and phrases in his or her pseudocode that are in line with basic computer operations, then the translation from the pseudocode algorithm to a specific programming language becomes quite simple. We could break down the computers operations into six basic operations and represent these operations in pseudocode. Each operation can be represented as an English instruction with keywords and indentation to signify a particular control structure: 1. A computer can receive information when a computer is required to receive information or input from a particular source, whether it is a keyboard, disk or other source, the verbs Read and Get can be used e.g. Read student name Get system date Read number_1, number_2 Each example uses a single verb, Read or Get, followed by one or more nouns to indicate what data is required to be obtained. 2. A computer can put out information when a computer is required to supply information or output to a device the verbs Print, Write or Put could be used e.g. Print student number Write Program completed Write customer record to master file Put out name, address, postcode 3. A computer can perform arithmetic most programs require the computer to perform some sort of mathematical calculation, or formula. You could use actual mathematical symbols or the words for those symbols e.g. Add Number to Total Total = Total + Number Divide Totalmarks by Studentcount SalesTax = Costprice * 0.10 Compute C = (F 32) * 5/9 4. A computer can assign a value to a piece of data there are many cases where a programmer will need to assign a value to a piece of information. Firstly to give data an initial value in pseudocode the verbs, Initialise or Set can be used. Secondly to assign a FILE=Programming Concepts and Design.doc by Greg Tisdell Updated on 23 March 2009 4

value as a result of some processing, the symbol = is written. Thirdly, to keep a piece of information for later use the verbs Save or Store could be used e.g. Initialise total accumulators to zero Set StudentCount to 0 TotalPrice = CostPrice + SalesTax Store CustomerNumber in LastCustomerNumber 5. A computer can compare two pieces of information and select one of two alternatives an important ability is the comparison of two pieces of information and then as a result of the comparison select on of two alternate actions. To represent this operation in pseudocode the keywords IF, THEN and ELSE can be used e.g. IF student is parttime THEN Add 1 to parttimecount ELSE Add 1 to fulltimecount ENDIF Note the use of indentation to emphasise the THEN and ELSE options and the use of the delimiter ENDIF to close the operation. 6. A computer can repeat a group of actions when there is a sequence of steps which need to be repeated, the keywords DOWHILE and ENDDO could be used e.g. DOWHILE studenttotal < 50 Read student record Write student name, address to report Add 1 to Studenttotal ENDDO Once again note the use of indentation. It is easy to read where the loop starts and ends. Alternatives to the above could be WHILE and ENDWHILE.. FILE=Programming Concepts and Design.doc by Greg Tisdell Updated on 23 March 2009 5