1 / 14

Techniques for designing code

Techniques for designing code. Storyboards Text (aka pseudocode) Diagrams Flowcharts (a procedural technique shown in text) Directed lines indicate flow of execution UML activity diagrams (an OO technique) UML is an OO standard for diagramming for OO systems

kyna
Download Presentation

Techniques for designing code

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. Techniques for designing code • Storyboards • Text (aka pseudocode) • Diagrams • Flowcharts (a procedural technique shown in text) • Directed lines indicate flow of execution • UML activity diagrams (an OO technique) • UML is an OO standard for diagramming for OO systems • Directed lines indicate flow of execution ACS-1805

  2. Techniques for designing code A storyboard in text form: • Do the following steps in order • alien moves up • alien says "Slithy toves?" • robot's head turns around • robot turns to look at alien • Do together • robot moves toward the alien • robot legs walk • alien moves down • If robot is shorter than rock • robot’s neck moves up • robot’s neck moves down • robot turns to face the camera • robot blushes • robot says “Houston, we have a problem!” ACS-1805

  3. Flowchart for Action Sequence Action 1 Action 2 … A simple sequence of actions. Looks the same in UML. ACS-1805

  4. Action Sequence A simple sequence of actions is a Do in order structure in Alice ACS-1805

  5. UML for Parallelism If a set of actions are to be done at the same time they can be represented in a UML activity diagram as Action 1 Action n … ACS-1805

  6. Text Flowchart If a set of actions are to be done at the same time they can be represented in a flowchart as Action 1 Action n … ACS-1805

  7. Parallel Set of Actions A Do together structure in Alice specifies that certain actions are to be done at the same time… i.e. in parallel ACS-1805

  8. Flowchart for If/Else expression false true action(s) when true action(s) when false An if/else results in one of two actions being executed depending on the truth or falsity of some expression ACS-1805

  9. UML for If • As a UML activity diagram [false expression] [true expression] Actions for true expression Actions for false expression ACS-1805

  10. If/Else expression ACS-1805

  11. Flowchart for Loop Set index to 0 Loop action(s) executed while an index goes from 0 up to a limit Increment index index < limit? true Loop action(s) false ACS-1805

  12. UML for Loop Loop action(s) executed while an index goes from 0 up to a limit Set index to 0 Increment index Loop action(s) [index < limit] [index >= limit] ACS-1805

  13. Loop Loop action(s) executed while an index goes from 0 up to but not including a limit *Also: see the more complicated version of loop Need to build this expression ACS-1805

  14. A UML diagram for Robot Discovering Alien Alien moves up Alien says “Slithy toves?” Robot turns head around Robot faces alien Need to modify this to accommodate the spider robot moving its head up/down as done on pages 69-71 Index  1 Limit  distance between alien and robot Increment index Robot moves 1m towards alien Robot leg moves Robot other leg moves [Index < limit] [Index >= limit] Alien moves down Robot faces camera Robot blushes Robot says “Houston, we have a problem!” ACS-1805

More Related