Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.

Slides:



Advertisements
Similar presentations
Programming Logic and Design Fourth Edition, Introductory
Advertisements

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider
Chapter 2: Input, Processing, and Output
Modules, Hierarchy Charts, and Documentation
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 3 Planning Your Solution
The Program Design Phases
PRE-PROGRAMMING PHASE
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Your Interactive Guide to the Digital World Discovering Computers 2012.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction 01_intro.ppt
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
Structured COBOL Programming, Stern & Stern, 9th edition
Simple Program Design Third Edition A Step-by-Step Approach
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
The Software Development Life Cycle. Software Development SDLC The Software Development Life-Cycle Sometimes called the program development lifecycle.
Programming Concepts Chapter 3.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Chapter 1 Introduction to Structured Design. Introduction  System  A combination of people, equipment, and procedures that work together to perform.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
1 Program Planning and Design Important stages before actual program is written.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 14 Programming and Languages McGraw-Hill/Irwin Copyright © 2008 by The McGraw-Hill Companies, Inc. All rights reserved.
Programming and Languages Dept. of Computer and Information Science IUPUI.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Algorithms and Flowcharts
Chapter 2: Input, Processing, and Output
Chapter 2- Visual Basic Schneider
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Algorithm and Ambiguity
An Introduction to Visual Basic .NET and Program Design
Computer Programming.
VISUAL BASIC – CHAPTER ONE NOTES An Introduction to Visual Basic
Chapter 2- Visual Basic Schneider
Chapter 1 Introduction(1.1)
Chapter 2- Visual Basic Schneider
Algorithm and Ambiguity
ICT Gaming Lesson 2.
Chapter 2: Input, Processing, and Output
Basic Concepts of Algorithm
Programming Logic and Design Eighth Edition
Presentation transcript:

Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program

2 2.1The Program Development Cycle Problem solving principles –Completely understand the problem –Devise a plan to solve it –Carry out the plan –Review the results Writing a program –1) Analyze the problem –2) Design the program –3) Code the program –4) Test the program

3 1. Analyze the Problem Identify desired results (output) Determine input needed to produce those results Example: Create a program to generate 6 numbers to play the lottery –Problem must be more specific –Desired results: 6 different positive integers within the range of 1 to 40

4 2. Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step method to solve a problem or complete a task Algorithms must be: –Well defined –Well ordered –Must produce some result –Must terminate in a finite time

5 3. Code the program Translate charts or pseudocode (ordinary language) into program code Add statements to document what the code does –Internal documenation –External documentation Each programming language uses its specific syntax

6 4. Test the program In analysis phase: continually ask questions –Did I interpret data correctly? –Does program fulfill requirements? Etc… In design phase: use desk-checking to walk through the program In coding phase: software will alert you to errors in syntax Finally, check your program with as many sets of test data as possible

7 2.2 Program Design Modular programming –Determine the major tasks that the program must accomplish. Each of these tasks will be a module. –Some modules will be complex themselves, and they will be broken into submodules, and those submodules may also be broken into even smaller modules. –This is called top-down design

8 The Sale Price Example A local department store needs to develop a program which, when given an item’s original price and the percentage it is discounted, will compute the sale price, with sales tax. Output required: name of item, discounted price, amount of sales tax, total price Input required: name of item, original price, percent discounted Formulas required: SalePrice = OriginalPrice – AmountSaved AmountSaved = OriginalPrice * (DiscountRate/100) Tax = SalePrice * TaxRate TotalPrice = SalePrice + Tax

9 Top Down Design The first illustration of top down design describes the 3 fundamental tasks that are required in the Sale Price example: –Input –Perform Calculations (Process) –Output Input Perform Calculations Output Input variables: AmountSaved = Display: OriginalPrice * DiscountRate/100 TotalPrice ItemNameSalePrice = OrigialPrice-AmountSaved DiscountRateTax = SalePrice * TaxRate OriginalPriceTotalPrice = SalePrice + Tax

10 A Code Module Performs a single task Is self-contained and independent of other modules Is relatively short – less than 1 page A module is called by the calling module A call statement causes a called module to be executed; control is transferred from the calling module to the called module The main module is the controller of all sub- modules

11 The Hierarchy Chart Like an organization chart – shows position of modules in the program. Depicts what modules exist and how they are related. Large programs need a “map” for documentation. One page of code per module – keeps the program manageable. We will have very small modules while getting comfortable using these tools.

12 Hierarchy Chart Sample Hierarchy Chart for the Sale Price Program:

13 2.3Coding, Documenting, and Testing Coding –Coding is done in a specific programming language. We will use pseudocode. –This phase should only begin after a solid design exists. Documenting –Code needs to contain documentation that describes to the reader what the code is doing –Two types of comments are used for documentation Internal and external documentation –Internal documentation is for the programmers to read –External documentation is for the user

14 2.3Coding, Documenting, and Testing Testing –Create test data that will be used to check the program’s correctness. Use desk checking (or walking through a program by hand with a set of data that you know the answer to) –Check that the program will catch errors by using test data designed to create errors –The more testing of various types of data you can use, the more likely you are to have a program that is free of errors.

15 Types of Errors Syntax errors: a violation of the programming language’s rules for creating valid statements –May be caused by incorrect grammar or punctuation, or misspelling a keyword –The program will not run at all with syntax errors Logic errors: the program runs, but does not produce the expected results –May be caused by using an incorrect formula, or incorrect sequence of statements, etc. –Sometimes called runtime errors –These errors can be detected during the desk checking phase of the programming cycle.

Commercial Programs: Testing and Documenting External documentation Purposes: 1.Documentation in a user’s guide or on- screen help system provides information about the program for the end users 2.Documentation in a maintenance manual provides information about how the program code accomplishes its purposes

17 The User’s Guide Usually written during alpha or beta test phases Written by a technical writer Forms of user’s guides: –Tutorials –Thematic approach –Alphabetical order

18 Documentation for other programmers Program maintenance manual –For programming experts to help them fix or enhance code written by other programmers Design documentation –Written by programmer to explain rationale behind methods and code used Trade Study documentation –A research tool –An attempt to find the best solution

Structured Programming A method for designing and coding programs in a systematic, organized manner It combines the principles of top-down design, modularity and the use of the three accepted control structures of sequence, repetition and selection Sequence, repetition and selection can be expressed in pseudocode, or with flowcharts

20 Flowcharts A tool for programmers to design programs –Describes the flow of a program module’s execution with diagrams –Completely different from hierarchy charts –Connected symbols are used to describe sequence, repetition, and selection structures –Some prefer to use flowcharting to learn how to express algorithms, and others prefer to use pseudocode –Many programs are designed with a combination of pseudocode and flowcharts

21 Flowchart Symbols

22 Control Structures Sequence –in sequential order. –The simplest of control structures – start at the beginning and continue in sequential order. Repetition – repeat statements more than once –Also called a loop, it needs a stop condition, i.e, the program will continue to loop until some condition is met. Selection – selectively execute statements –Called a branch, it requires a condition to determine when to execute statements.

23 Flowchart for a Loop Loop or repetition structure flowchart:

24 Flowchart for a Decision Decision or selection structure flowchart:

An Introduction to GUIs and OOP GUI – Graphical User Interface –Users interact with software using a mouse, to select from menu choices, clicking on buttons, etc. –Development of GUI software uses tools specifically designed for that task. –Event-driven programming is the development of software where the flow of control is based on the user’s clicking on menus and buttons, etc. These user actions are called events. Event-driven programming still uses the basic principles of structured programming – program modules, control structures, good programming style, and program testing.

26 Object Oriented Programming Focus is on the objects that will be used to solve the problems. Object – a structure that contains attributes and methods (data and process) Object-oriented design starts with identifying the required objects. Java, C++, JavaScript and others are languages based on object-oriented programming

27 Importance of Structured Programming Structured, event-driven, and object- oriented programming techniques are not separate form each other. All require the basic principles of structured programming – program modules, control structures, good programming style, and program testing.

28 Style Pointers Write modular programs Use descriptive variable names Provide a welcome message for the user Use a prompt before an input Identify program output Document your programs

29 Pseudocode Language (Ch 2) In this chapter we added a way to create and call modules in our programs. InputAssignment Input Variable Set Variable = 10 Set Variable = AnotherVariable OutputArithmetic Operations Write “literal text” ( ) ^ * / + - Write Variable Write “literal text”, Variable Create a module Call a sub-module ModuleName Call ModuleName …. End