The Pseudocode Programming Process Chapter 9. Summary of Steps in Building Classes and Routines.

Slides:



Advertisements
Similar presentations
Introduction to Recursion and Recursive Algorithms
Advertisements

PROBLEM SOLVING TECHNIQUES
Coding. Steps to Success 1.Create a PLAN including a detailed statement of requirements (SORs) 2.Write algorithms based on the SORs 3.Write pseudocode.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
The Pseudocode Programming Process Chapter 9. Outline  Introduction  Design the routine.  Code the routine.  Check the code.  Clean up loose ends.
1 Program Design Language (PDL) Slides by: Noppadon Kamolvilassatian Source: Code Complete by Steve McConnell, Chapter 4.
Chapter 2 - Problem Solving
8 Algorithms Foundations of Computer Science ã Cengage Learning.
1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
Chapter 2: Algorithm Discovery and Design
Computers: Tools for an Information Age
Computer Science 1620 Programming & Problem Solving.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 2: Algorithm Discovery and Design
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
1 Working with Classes Chapter 6. 2 Class definition A class is a collection of data and routines that share a well-defined responsibility or provide.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Basic Concepts Chapter 1 Objectives
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
Introduction to High-Level Language Programming
Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
11 Values and References Chapter Objectives You will be able to: Describe and compare value types and reference types. Write programs that use variables.
Comp 245 Data Structures Software Engineering. What is Software Engineering? Most students obtain the problem and immediately start coding the solution.
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
DATA STRUCTURE & ALGORITHMS CHAPTER 3: STACKS. 2 Objectives In this chapter, you will: Learn about stacks Examine various stack operations Discover stack.
Chapter 11Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
SE: CHAPTER 7 Writing The Program
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
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.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
The Software Development Process
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Revealing the Secrets of Self-Documenting Code Svetlin Nakov Telerik Corporation
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
PRODUCT IMPLEMENTATION Chapter 8 Tawatchai Iempairote September 23, 2041.
1 Chapter 16 Component-Level Design. 2 Component-Level Design  the closest design activity to coding  the approach: review the design description for.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Algorithms and Pseudocode
Lecture 3: Developing Procedural Thinking (How to think like a programmer) B Burlingame 16 Feb 2016.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
Today… Functions, Cont.: –Designing functions. –Functional Decomposition –Importing our own module –A demo: Functional solution to assignment 2. Winter.
Principles of Programming & Software Engineering
Pointers and Linked Lists
GC211Data Structure Lecture2 Sara Alhajjam.
Principles of Programming and Software Engineering
The Pseudocode Programming Process
Topic: Functions – Part 2
Understand the Programming Process
Unit# 9: Computer Program Development
Chapter 16 Component-Level Design
Understand the Programming Process
Program Design Language (PDL)
Week 4 Lecture-2 Chapter 6 (Methods).
Data Structures & Algorithms
Introduction To Software Development Environment
Presentation transcript:

The Pseudocode Programming Process Chapter 9

Summary of Steps in Building Classes and Routines

Steps in Creating a Class 1) Create a general design for the class –Define the class’s specific responsibilities. –Define what “secrets” the class will hide. –Determine whether the class will be derived from another class, and whether other classes will be allowed to derive from it. –Identify the class’s key public methods. –Identify and design any non trivial data members used by the class.

Steps in Creating a Class.. continue 2) Construct each routine within the class - See next slides … 3) Review and test the class as a whole - After the class as a whole becomes operational, the class as a whole should be reviewed and tested

Steps in Building a Routine The major activities involved in creating a routine are –designing the routine, –checking the design, –coding the routine, and –checking the code

Steps in Building a Routine

Experts have developed numerous approaches to creating routines, and one of the favorite approach is the Pseudocode Programming Process Or PPP

Pseudocode Programming Process an informal, English-like notation for describing how an algorithm, a routine, a class, or a program will work. defines a specific approach to using pseudocode to streamline the creation of code within routines.

Guidelines for using pseudocode effectively Use English-like statements that precisely describe specific operations. Avoid syntactic elements from the target programming language. Describe the meaning of the approach rather than how the approach will be implemented in the target language. Refine the pseudocode in more and more detail until it seems as if it would be easier to simply write the code.

Example of Good Pseudocode Keep track of current number of resources in use If another resource is available Allocate a dialog box structure If a dialog box structure could be allocated Note that one more resource is in use Initialize the resource Store the resource number at the location provided by the caller Endif Return TRUE if a new resource was created; else return FALSE

Example of Bad Pseudocode increment resource number by 1 allocate a dlg struct using malloc if malloc() returns NULL then return 1 invoke OSrsrc_init to initialize a resource for the operating system *hRsrcPtr = resource number return 0

The previous example is bad Pseudocode because.. it includes coding details such as *hRsrcPtr in specific C-language pointer notation, and malloc(), a specific C- language function It focuses on how the code will be written rather than on the meaning of the design. It gets into coding details—whether the routine returns a 1 or a 0

Example Write a Pseudocode to read 10 numbers and find out the average

Set default summation to 0 If number of read numbers less than 10 Read another number Add it to summation Endif Divide summation by 10 and print the result

The benefits you can expect from using this style of pseudocode 1) Pseudocode makes reviews easier. –You can review detailed designs without examining source code 2) Pseudocode makes changes easier. –A few lines of pseudocode are easier to change than a page of code. 3) Pseudocode minimizes commenting effort. –In the PPP, the pseudocode statements become the comments 4) Pseudocode is easier to maintain than other forms of design documentation.

Constructing Routines Using the PPP ● Design the routine ● Code the routine ● Check the code ● Clean up leftovers ● Repeat as needed

Design the routine Check the prerequisites Define the problem the routine will solve Name the routine Decide how to test the routine Think about error handling Think about efficiency Research functionality available in the standard libraries Research the algorithms and data types Write the pseudocode Check the pseudocode Try a few ideas in pseudocode, and keep the best (iterate)

Code the Routine Write the routine declaration Turn the pseudocode into high-level comments Fill in the code below each comment Check whether code should be further factored

Check the Code Mentally check the routine for errors Compile the routine Step through the code in the debugger Test the code Remove errors from the routine

Clean Up Leftovers Check the routine’s interface. (all parameters used) Check for general design quality Check the routine’s data. Check the routine’s statements and logic. Check the routine’s layout. Check the routine’s documentation Remove redundant comments.