1 / 7

More Functional Decomposition

More Functional Decomposition. Intro to Computer Science CS 1510 Dr. Sarah Diesburg. Questions on yesterday’s lab?. Let’s create our own rock, paper, scissors hierarchical solution tree together. Functional Cohesion.

garretth
Download Presentation

More Functional Decomposition

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. More Functional Decomposition Intro to Computer Science CS 1510 Dr. Sarah Diesburg

  2. Questions on yesterday’s lab? • Let’s create our own rock, paper, scissors hierarchical solution tree together

  3. * Special thanks to Dr. McCormick for the use of his materials from the book: Dale, Weems, and McCormick. Programming and Problem Solving with ADA 95. Functional Cohesion • Functional cohesion*– each module should do just one thing and do it well

  4. Which module lack functional cohesion? • Process credit card transactions • Determine weight and pick color • Print final score • Pick floor covering and large screen television • Determine costs of tuition and entertainment expenses • Determine the cost of baking a cake • Ask user preferences • Determine average and letter grade

  5. How to write cohesive modules • Think about how you would solve the subproblem by hand • Begin writing down the major steps • If the step is simple enough to implement directly in Python, it is already concrete (do not refine it further) • If you still need to think about implementing the step as a series of smaller steps, it is still abstract

  6. How to write cohesive modules (cont.) • If you are trying to write a series of steps and get overwhelmed by the details, you probably bypassed one or more levels of abstraction • Look for pieces that can be written as more abstract steps to be broken down later

  7. Example: Card Game War • Let’s use the hierarchical solution tree we built to convert our script version into a version with functions that map to each module!

More Related