1 / 11

Flowcharts

Flowcharts. adapted from A Visual Tool for Logic Design and Program Planning, by Dr. Donald Bell, Cal Poly, 1999 updated April, 2010. What Is a Flowchart?. Diagram with lines (arrows) and symbols to show how something works can show how code works in a program

liam
Download Presentation

Flowcharts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Flowcharts adapted from A Visual Tool for Logic Design and Program Planning, by Dr. Donald Bell, Cal Poly, 1999 updated April, 2010

  2. What Is a Flowchart? • Diagram with lines (arrows) and symbols to show how something works • can show how code works in a program • definition and symbols (programming) • can also be used to help understand other processes • criminal justice system flowchart (symbols somewhat different than for programming)

  3. Flowcharts • Reasons for using flowcharts • similar to reasons for using pseudocode • Special symbols used in flowcharts • Rules for Successive Refinement

  4. Purpose of Flowcharts • To plan your logic prior to writing your program • Can be very helpful when you have complex conditional logic (the graphics help visualize the logic flow) • Assists in applying "successive refinement" ("top down" analysis) • Can also be used to document your logic • not used as much with object oriented code

  5. Successive Refinement • Equally applicable whether you use flowcharting or pseudocode • Start at the very "top level" • a one line statement of your program's purpose • break it down by stages into greater and greater levels of detail • Successive refinement stops when there is enough detail to write the program • Each flowchart symbol is a basic building block (like Tinker Toys orLego blocks) • these are assembled into complex structures • assembled in specific ways

  6. Flowcharting Symbols • Like pseudocode there are no fixed "standards", but there are conventions • Flowcharts use ovals, rectangles and diamonds • ovals start and end the logic flow • rectangles are for imperative statements • diamonds are for decisions • Some people use other symbols such as parallelograms for input and output, etc.

  7. Rules for Applying Successive Refinement Using Flowcharts • Can replace one rectangular block with several more detailed ones • Can replace a rectangular block with one including logic or iteration (looping) • Each block has one entry point, and one exit point (very important!) • but different statements can enter it there • Flow does not terminate until you get to a stop or end symbol

  8. Rules for Applying Successive Refinement Using Flowcharts - 2 • Start with a simple chart that summarizes the whole system (high level view) • use separate symbols for each major aspect, e.g., input, processing, output • Decompose each major aspect into a more detailed flow chart • e.g., input could decompose into: prompt user, read input, check input, if wrong give error message and prompt for good data

  9. Flowcharts & OO Programs • Flowcharts use a sequential logic • top to bottom • OO programming is often "event driven" • objects fire methods in response to messages • However flowcharting is suitable for developing code within methods

  10. UML Diagrams • Identify tasks (use cases) • Identify which object should handle a task • Identify messages sent between objects • Draw objects and messages into a diagram • example of a "use case diagram (which shows a class, properties, methods)

  11. Review • Draw flowcharts for sequence, selection and iteration control structures • Draw a flowchart for code that counts the number of students with GPAs of 3.0 or higher and then prints the total • Will need to use sequence, selection and iteration

More Related