1 CS 106 Computing Fundamentals II Chapter 13 “Design Specification” Herbert G. Mayer, PSU CS status 6/29/2013 Initial content copied verbatim from CS.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Advertisements

Process Design (Specification)
Introduction to Flowcharting
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
Use Flowchart Symbols for Structured Programming
Chapter 2 - Problem Solving
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Chapter 2 - Problem Solving
1 CS 106 Computing Fundamentals II Chapter 12 “Design Requirements” Herbert G. Mayer, PSU CS status 6/29/2013 Initial content copied verbatim from CS 106.
1 CS 106, Winter 2009 Class 3, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
ITEC113 Algorithms and Programming Techniques
1 CS 106, Winter 2009 Class 2, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
1 CS 106, Winter 2009 Class 4, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
Chapter 2- Visual Basic Schneider
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 – Graphs and Charts: Delivering a Message Robert Grauer and Maryann Barber Exploring.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
Introduction to Software Engineering CS-300 Fall 2005 Supreeth Venkataraman.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Chapter 3 Planning Your Solution
Flow Charts. Thinking Creatively Flow Charts START END Is A==6? No A = 1 Yes Print A A = A + 1.
Introduction to Computers and Programming
CSC103: Introduction to Computer and Programming
Microsoft Excel How to make a SPREADSHEET. Microsoft Excel IT is recommended that you have EXCEL running at the same time. You can try what you are reading.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
1 CS 106 Computing Fundamentals II Chapter 17 “Introduction To VBA” Herbert G. Mayer, PSU CS status 6/30/2013 Initial content copied verbatim from CS 106.
1 CS 106 Computing Fundamentals II Chapter 29 “Creating A User Form” Herbert G. Mayer, PSU CS Status 7/4/2013 Initial content copied verbatim from CS 106.
Process Design (Requirements). Recall the Four Steps of Problem Solving * Orient Plan Execute Test These apply to any kind of problem, not just spreadsheet.
1 CS 106 Computing Fundamentals II Chapter 7 “Showing Developer Tab” Herbert G. Mayer, PSU CS status 6/17/2013 Initial content copied verbatim from CS.
1 CS 106 Computing Fundamentals II Chapter 34 “Conditionals In Excel” Herbert G. Mayer, PSU CS Status 7/17/2013 Initial content copied verbatim from CS.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Programming Concepts Chapter 3.
Advanced Excel Microsoft Excel Excel - Overview Calculator Create budgets, analyze results Perform Financial Analysis Creating charts Organizing.
Algorithms CS139 – Aug 30, Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.
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.
Introduction to Programming with RAPTOR
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
ITEC113 Algorithms and Programming Techniques
1 CS 106 Computing Fundamentals II Chapter 84 “Array Formulae” Herbert G. Mayer, PSU CS status 6/14/2013 Initial content copied verbatim from CS 106 material.
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
Programming with Microsoft Visual Basic th Edition
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
1 CS 106 Computing Fundamentals II Chapter 23 “Controls And Events” Herbert G. Mayer, PSU CS Status 7/5/2013 Initial content copied verbatim from CS 106.
Algorithms CS280 – 10/20/05. Announcement  Part 1 of project 2 due.  Read chapters 10, 7 for this unit  Tuesday we will also be in the classroom We.
Slide Copyright © 2009 Pearson Education, Inc. Slide Copyright © 2009 Pearson Education, Inc. Welcome to MM150 – Unit 4 Seminar Unit 4 Seminar.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Inductive and Deductive Reasoning  The pre-requisites for this chapter have not been seen since grade 7 (factoring, line constructions,..);
Algorithms and Pseudocode
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Chapter 5 The Time Value of Money— The Basics. Copyright ©2014 Pearson Education, Inc. All rights reserved.5-2 Slide Contents Learning Objectives Principles.
1 CS 106 Computing Fundamentals II Chapter 42 “Sub Procedures And Functions” Herbert G. Mayer, PSU CS Status 8/5/2013 Initial content copied verbatim from.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
CMSC 104, L041 Algorithms, Part 1 of 3 Topics Definition of an Algorithm Example: The Euclidean Algorithm Syntax versus Semantics Reading Sections 3.1.
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
Algorithms and Flowcharts
ALGORITHMS AND FLOWCHARTS
CS 106 Computing Fundamentals II Chapter 5 “Excel Basics for Windows”
Chapter 2- Visual Basic Schneider
Theory of Computation Turing Machines.
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
CS 106 Computing Fundamentals II Chapter 69 “Event Loop”
Basic Concepts of Algorithm
Presentation transcript:

1 CS 106 Computing Fundamentals II Chapter 13 “Design Specification” Herbert G. Mayer, PSU CS status 6/29/2013 Initial content copied verbatim from CS 106 material developed by CS professors: Cynthia Brown & Robert Martin

2 Syllabus Problem Solving Techniques Problem Solving Techniques “When” Problems “When” Problems Gantt Charts Gantt Charts Napoleon’s Army in Russia Napoleon’s Army in Russia How Many/How Much How Many/How Much Flow Charts “How” Flow Charts “How” Simple Process Simple Process Variables Variables Algorithm Algorithm From Use Cases to Flow Chart From Use Cases to Flow Chart

3 Four Steps of Problem Solving * OrientPlanExecuteTest These steps are generic; they apply to any kind of problem, not just spreadsheet development, programming, or process design, but we will focus on those in CS 106 * Carlson and Bloom, “The Cyclic Nature of Problem Solving: An Emergent Multi-Dimensional Problem Solving Framework”, Educational Studies in Mathematics, Vol. 58 Number 1,

4 Specification We covered requirements (the orient phase… what we want to have happen)We covered requirements (the orient phase… what we want to have happen) Now we’re ready to talk about the specification or design phase (the planning phase… how it should happen)Now we’re ready to talk about the specification or design phase (the planning phase… how it should happen) Our tool for developing and communicating a design is the flow chartOur tool for developing and communicating a design is the flow chart 4

5 Problem-Solving Techniques Flowcharts are a visual technique for designing a process (figuring out how to do something)Flowcharts are a visual technique for designing a process (figuring out how to do something) Before we learn about flow charts (a technique for “how” problems), let’s look at a couple of useful visual techniques for solving other kinds of problemsBefore we learn about flow charts (a technique for “how” problems), let’s look at a couple of useful visual techniques for solving other kinds of problems For more on the ideas here, see Dan Roam’s website, more on the ideas here, see Dan Roam’s website, 5

6 “When” Problems Suppose we want to make a master plan showing team leaders when each step of a complex process they are directing and coordinating will take placeSuppose we want to make a master plan showing team leaders when each step of a complex process they are directing and coordinating will take place Thus we need a When -> TimelineThus we need a When -> Timeline Since we need to convey a large amount of precise information, a Gantt Chart is an appropriate visual toolSince we need to convey a large amount of precise information, a Gantt Chart is an appropriate visual tool 6

7 Gantt Chart Example 7

8 GANTT with Dependencies 8

9 Baseline GANTT (shows comparison, change) 9

10 Napoleon’s Army in Russia – drawn by Charles Minard 10

11 How Many/How Much Suppose we need to answer how many/how muchSuppose we need to answer how many/how much Bar charts are often usedBar charts are often used Pie charts are another option (controversial because it is harder to compare pie slices than bars)Pie charts are another option (controversial because it is harder to compare pie slices than bars) There are plenty of interesting and clever variations… such as the word usage chart (next slide)There are plenty of interesting and clever variations… such as the word usage chart (next slide) 11

12 Variation on Bar Chart Word Usage in 2008 McCain Speech 12

13 Example: Seeing the Market These charts show how much versus when. They give much more insight than a numerical list of prices. 13

14 Flowcharts: “How” Flowcharts are a visual tool for specifying a processFlowcharts are a visual tool for specifying a process They can be as high level or as detailed as we need them to beThey can be as high level or as detailed as we need them to be They use symbols and arrows to represent steps and choicesThey use symbols and arrows to represent steps and choices 14

15 Flowchart Symbols Flowline: Connects symbols and indicates the flow of logic. It is a one way street. Input/Output: Data to be read or displayed are described inside. Terminal: Represents the beginning or end of a task. Processing: The process description is included inside the symbol. Decision: Used for logic/comparison operations. Has one entry and two exits. 15

16 One more… Continuation 16

17 Simple Processes A simple process has no decisions in it; you always do it the same wayA simple process has no decisions in it; you always do it the same way As a result, its flowchart is just a straight line of boxes connected by arrowsAs a result, its flowchart is just a straight line of boxes connected by arrows Example: most recipes, instruction sheets with assemble-it-yourself furniture, simple calculationsExample: most recipes, instruction sheets with assemble-it-yourself furniture, simple calculations 17

18 Simple Process: Compound Interest Goal: Given a number N of years, an amount P of money (principal), and an annual interest rate R, calculate the total amount of money T you will have after P is invested for N years at rate R, using interest which is compounded annually. T = P(1+R) N Goal: Given a number N of years, an amount P of money (principal), and an annual interest rate R, calculate the total amount of money T you will have after P is invested for N years at rate R, using interest which is compounded annually. T = P(1+R) N Test 1: P = 100, N = 1, R = 5% (.05): 105 Test 2: P = 100, N = 7, R =.05: 140 Test 3: P = 0, N = 7, R =.05: 0 Test 4: P = 100, N = 7, R = 0: 100 Test 5: P = 100, N = 0, R =.05:

19 Just for interest P = 100, N = 20, R =.05 gives 265 P = 100, N = 30, R =.05 gives 432 By contrast, simple interest at 5 percent gives $5 per year, so after 20 years you have a total of $200; after 30 you have $250. If R is, say, 8%, the difference is even more striking. 19

20 Storing Information In this process we have to keep track of some information, like how much principal we have, what the interest rate is, etc.In this process we have to keep track of some information, like how much principal we have, what the interest rate is, etc. We’ll use VBA variables to store these valuesWe’ll use VBA variables to store these values

21 Variables Variable is a named container used to refer to a quantity whose value is stored, can be recalled, and can changeVariable is a named container used to refer to a quantity whose value is stored, can be recalled, and can change You can think of a variable as the name of a container that holds a valueYou can think of a variable as the name of a container that holds a value Constant is a name for a quantity whose value does not changeConstant is a name for a quantity whose value does not change A spreadsheet cell is a good example of a container that can hold a valueA spreadsheet cell is a good example of a container that can hold a value 21

22 Math Variables vs. Programming/Spreadsheet Variables In math, a variable is used in an equation to represent some scalar quantityIn math, a variable is used in an equation to represent some scalar quantity Given the equation 3x = x + 6, we can solve this equation for x and get x = 3. You can check the correctness by substituting 3 for x on each side and seeing that you get the same value (9)Given the equation 3x = x + 6, we can solve this equation for x and get x = 3. You can check the correctness by substituting 3 for x on each side and seeing that you get the same value (9) An “equation” like x = x + 1 would be meaningless; it has no solution; we call it a contradictionAn “equation” like x = x + 1 would be meaningless; it has no solution; we call it a contradiction 22

23 Programming Variables Programming variables and spreadsheet locations are a place to store a value, which can changeProgramming variables and spreadsheet locations are a place to store a value, which can change The assignment statement x = 4 means to store the value 4 in location x. It is not purely an equation, though it looks like oneThe assignment statement x = 4 means to store the value 4 in location x. It is not purely an equation, though it looks like one The pair of assignments:The pair of assignments: x = 4 x = x + 1 means to first store a 4 in location x, and then take the current contents (4), add 1, and store the result (5) in location x. The order of the statements is extremely important. 23

24 Compound Interest Calculator begin R = annual rate N = num. of years P = principal R = annual rate N = num. of years P = principal T = P*(1+R)^N Output T end 24 We used variables R, N, P, and T. Arrows in a flowchart are like one-way streets; once you go down one, you can’t back up

25 Example Spreadsheet The spreadsheet called Interest Calculator 1 has this formula in itThe spreadsheet called Interest Calculator 1 has this formula in it Let’s see how to build this spreadsheetLet’s see how to build this spreadsheet 25

26 Algorithm The interest rate calculator is an example of a simple algorithm: an effective method in which a sequence of well-defined instructions for completing a task will, given an initial state, proceed through a well-defined series of steps, eventually terminating in an end-stateThe interest rate calculator is an example of a simple algorithm: an effective method in which a sequence of well-defined instructions for completing a task will, given an initial state, proceed through a well-defined series of steps, eventually terminating in an end-state Thought to be named for Al-Khwārizmī, Persian astronomer and mathematicianThought to be named for Al-Khwārizmī, Persian astronomer and mathematician 26

27 Back to the Candy Machine… 27

28 User Interface The first step in the design is often to think about the user interfaceThe first step in the design is often to think about the user interface What does the user interact with?What does the user interact with? What are the possible events that can occur?What are the possible events that can occur?

29 Candy Machine Objects, Events Coin slot User inserts a coin Candy slot Opens so a piece of candy can come outHandle The user attempts to turn the handle Coin receptacle It can be full, partly full, or empty These are all the objects in the requirements that have events However: how does the machine know if there is a correct coin in the coin slot? Or any coin at all? It looks like the handle turning mechanism needs to be able to check some things.

30 Handle Functions Turning the handle can send a coin to the coin receptacle. The handle only allows the correct coins through and won’t turn otherwiseTurning the handle can send a coin to the coin receptacle. The handle only allows the correct coins through and won’t turn otherwise The handle should not turn if the coin receptacle is fullThe handle should not turn if the coin receptacle is full The designer, a mechanical engineer, figures out whether she can build a handle mechanism like this within our budget, and what the tradeoffs areThe designer, a mechanical engineer, figures out whether she can build a handle mechanism like this within our budget, and what the tradeoffs are We won’t look at the mechanical aspect of this, but we can express the logical flow of the solution in a flow chartWe won’t look at the mechanical aspect of this, but we can express the logical flow of the solution in a flow chart 30

31 Turning the Handle The next slide shows the flowchart for the event where someone tries to turn the handle of the candy machineThe next slide shows the flowchart for the event where someone tries to turn the handle of the candy machine It shows the use of the begin/end, conditional, and process step boxesIt shows the use of the begin/end, conditional, and process step boxes

32 Handle Flowchart start begin attempt to turn handle correct coin in slot? handle does not turn handle turns coin goes into receptacle candy slot opens receptacle has room? end noyes noyes

33 From Use Cases to Flowchart In the candy machine example, we have several objects, but only one event that requires a process: trying to turn the handleIn the candy machine example, we have several objects, but only one event that requires a process: trying to turn the handle The use cases were various complete scenarios of an interaction with the machineThe use cases were various complete scenarios of an interaction with the machine We abstracted information from several use cases to design the handle turning eventWe abstracted information from several use cases to design the handle turning event We use the tests to make sure we put the pieces together correctlyWe use the tests to make sure we put the pieces together correctly

34 Event-Driven Design This type of design is called “event driven” because it works by analyzing what the events are in the process and what should happen as a result of each eventThis type of design is called “event driven” because it works by analyzing what the events are in the process and what should happen as a result of each event This has turned out to be a highly effective way of designing processesThis has turned out to be a highly effective way of designing processes And is used in VBAAnd is used in VBA 34