How to develop a program

Slides:



Advertisements
Similar presentations
“The study of algorithms is the cornerstone of computer science.” Algorithms Winter 2012.
Advertisements

Chapter 2 - Problem Solving
Chapter 2 - Problem Solving
19-1 Programming… The Pencil and Paper Computer The Pencil & Paper Instruction Set: (table on p148) The Operand specifies a memory location.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Using Algorithms Copyright © 2008 by Helene G. Kershner.
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
The Art of Programming Top-Down Design. The Art of Problem Solving The art of problem solving is the transformation of an English description of a problem.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Learning Objectives Data and Information Six Basic Operations Computer Operations Programs and Programming What is Programming? Types of Languages Levels.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
The Programming Process Define the problem* Make or buy software? Design the program * Code (write) the program Test (debug) the program Document the.
Chapter One An Introduction to Programming and Visual Basic.
CSE 190p wrapup Michael Ernst CSE 190p University of Washington.
Introduction to programming Carl Smith National Certificate Year 2 – Unit 4.
The Art of Programming. The process of breaking problems down into smaller, manageable parts By breaking the problem down, each part becomes more specific.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
How to develop a program CSE 160 University of Washington 1.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
How to develop a program CSE 140 University of Washington 1.
 Problem Analysis  Coding  Debugging  Testing.
CMSC 104, Version 8/061L05Algorithms2.ppt Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode Control Structures Reading Section 3.1.
Program design Program Design Process has 2 phases:
CST 1101 Problem Solving Using Computers
Introduction to Programming Part 1
ICS 3UI - Introduction to Computer Science
CS1010 Programming Methodology
Algorithms and Problem Solving
CSCI-235 Micro-Computer Applications
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Topic: Functions – Part 2
A451 Theory – 7 Programming 7A, B - Algorithms.
Think What will be the output?
Using Algorithms Copyright © 2008 by Helene G. Kershner.
Overview Instruction Codes Computer Registers Computer Instructions
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm and Ambiguity
2008/09/24: Lecture 6b CMSC 104, Section 0101 John Y. Park
Understand the Programming Process
Teaching Computing to GCSE
Using Algorithms Copyright © 2008 by Helene G. Kershner.
Problem Solving Techniques
How to develop a program
Designing Programs.
2008/09/22: Lecture 5 CMSC 104, Section 0101 John Y. Park
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
This Lecture Substitution model
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Chapter One: An Introduction to Programming and Visual Basic
The Programming Process
Understand the Programming Process
Algorithm and Ambiguity
How to develop a program
Program Design Language (PDL)
PYTHON: BUILDING BLOCKS Sequencing & Selection
Lecture 7 Algorithm Design & Implementation. All problems can be solved by employing any one of the following building blocks or their combinations 1.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Tonga Institute of Higher Education IT 141: Information Systems
This Lecture Substitution model
Tonga Institute of Higher Education IT 141: Information Systems
Computational Thinking
This Lecture Substitution model
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
CMPT 120 Lecture 16 – Unit 3 – Graphics and Animation
How to develop a program
Presentation transcript:

How to develop a program UW CSE 160 Winter 2017

Program development methodology: English first, then Python Define the problem Decide upon an algorithm Translate it into code Try to do these steps in order

Program development methodology: English first, then Python Define the problem Write an English description of the input and output for the whole program. (Do not give details about how you will compute the output.) Create test cases for the whole program Input and expected output Decide upon an algorithm Translate it into code Try to do these steps in order

Program development methodology: English first, then Python Define the problem Decide upon an algorithm Implement it in English Write the recipe or step-by-step instructions Test it using paper and pencil Use small but not trivial test cases Play computer, animating the algorithm Be introspective Notice what you really do May be more or less than what you wrote down Make the algorithm more precise Translate it into code Try to do these steps in order

Program development methodology: English first, then Python Define the problem Decide upon an algorithm Translate it into code Implement it in Python Decompose it into logical units (functions) For each function: Name it (important and difficult!) Write its documentation string (its specification) Write tests Write its code Test the function Test the whole program Try to do these steps in order

Program development methodology: English first, then Python Define the problem Decide upon an algorithm Translate it into code Try to do these steps in order It’s OK (even common) to back up to a previous step when you notice a problem You are incrementally learning about the problem, the algorithm, and the code “Iterative development”

The Wishful Thinking approach to implementing a function If you are not sure how to implement one part of your function, define a helper function that does that task “I wish I knew how to do task X” Give it a name and assume that it works Go ahead and complete the implementation of your function, using the helper function (and assuming it works) Later, implement the helper function The helper function should have a simpler/smaller task Can you test the original function? Yes, by using a stub for the helper function Often a lookup table: works for only 5 inputs, crashes otherwise, or maybe just returns the same value every time

ThinkPython 3.12 Why functions? It may not be clear why it is worth the trouble to divide a program into functions. There are several reasons: Creating a new function gives you an opportunity to name a group of statements, which makes your program easier to read and debug. Functions can make a program smaller by eliminating repetitive code. Later, if you make a change, you only have to make it in one place. Dividing a long program into functions allows you to debug the parts one at a time and then assemble them into a working whole. Well-designed functions are often useful for many programs. Once you write and debug one, you can reuse it.