Programming Rationale and Plan Fourth Version, Basic.


45 views
Uploaded on:
Description
Portray the components of unstructured spaghetti code. Portray the three fundamental structures ... Spaghetti code programs frequently work, yet are hard to peruse and ...
Transcripts
Slide 1

Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure

Slide 2

Objectives Describe the elements of unstructured spaghetti code Describe the three fundamental structures – arrangement, choice, and circle Use a preparing read Appreciate the requirement for structure Recognize structure Programming Logic and Design, Introductory, Fourth Edition

Slide 3

Objectives (proceeded with) Describe three unique structures – case, do-while, and do-until Programming Logic and Design, Introductory, Fourth Edition

Slide 4

Understanding Unstructured Spaghetti Code Spaghetti code – coherently growled program proclamations Can be the consequence of poor system plan Example: school confirmations criteria Programming Logic and Design, Introductory, Fourth Edition

Slide 5

Understanding Unstructured Spaghetti Code (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 6

Understanding Unstructured Spaghetti Code (proceeded with) Spaghetti code programs frequently work, however are hard to peruse and keep up Convoluted rationale for the most part requires more code Programming Logic and Design, Introductory, Fourth Edition

Slide 7

Understanding the Three Basic Structures Structure : an essential unit of programming rationale Any project can be built from just three essential sorts of structures Sequence Selection Loop Programming Logic and Design, Introductory, Fourth Edition

Slide 8

Understanding the Three Basic Structures (proceeded with) Sequence structure An arrangement of guidelines, performed consecutively with no spreading Programming Logic and Design, Introductory, Fourth Edition

Slide 9

Understanding the Three Basic Structures (proceeded with) Selection structure Asks an inquiry, then takes one of two conceivable blueprints taking into account the answer Also called a choice structure or an if-then-else Programming Logic and Design, Introductory, Fourth Edition

Slide 10

Understanding the Three Basic Structures (proceeded with) Dual-elective if : contains two options Programming Logic and Design, Introductory, Fourth Edition

Slide 11

Understanding the Three Basic Structures (proceeded with) Single-option if : contains one option Programming Logic and Design, Introductory, Fourth Edition

Slide 12

Understanding the Three Basic Structures (proceeded with) Single-option if Else proviso is not required Null case : circumstance where nothing is done Programming Logic and Design, Introductory, Fourth Edition

Slide 13

Understanding the Three Basic Structures (proceeded with) Loop structure Repeats an arrangement of activities taking into account the response to an inquiry Also called redundancy or emphasis Question is asked first in the most well-known type of circle Programming Logic and Design, Introductory, Fourth Edition

Slide 14

Understanding the Three Basic Structures (proceeded with) Loop structure Programming Logic and Design, Introductory, Fourth Edition

Slide 15

Understanding the Three Basic Structures (proceeded with) All rationale issues can be illuminated utilizing just these three Structures can be consolidated in a boundless number of ways Stacking : appending structures end-to End-structure articulations Indicate the end of a structure endif : closes an if-then-else structure endwhile : closes a circle structure Programming Logic and Design, Introductory, Fourth Edition

Slide 16

Understanding the Three Basic Structures (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 17

Understanding the Three Basic Structures (proceeded with) Any individual undertaking or venture in a structure can be supplanted by a structure Nesting : putting one structure inside another Indent the settled structure\'s announcements Block : gathering of explanations that execute as a solitary unit Programming Logic and Design, Introductory, Fourth Edition

Slide 18

Understanding the Three Basic Structures (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 19

Understanding the Three Basic Structures (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 20

Understanding the Three Basic Structures (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 21

Understanding the Three Basic Structures (proceeded with) Each structure has one passage and one way out point Structures connect to others just at section or leave focuses Programming Logic and Design, Introductory, Fourth Edition

Slide 22

Using the Priming Read Priming read (or preparing information ): Reads the main info information record Outside the circle that peruses whatever is left of the records Helps keep the system organized Analyze a flowchart for structure slowly and carefully Watch for unstructured circles that don\'t tail this order: First pose a question Take activity taking into account the answer Return to pose the question again Programming Logic and Design, Introductory, Fourth Edition

Slide 23

Using the Priming Read (proceeded with) Unstructured circle: Programming Logic and Design, Introductory, Fourth Edition

Slide 24

Using the Priming Read (proceeded with) Structured yet nonfunctional circle Programming Logic and Design, Introductory, Fourth Edition

Slide 25

Using the Priming Read (proceeded with) Functional yet non-organized circle Programming Logic and Design, Introductory, Fourth Edition

Slide 26

Using the Priming Read (proceeded with) Functional and organized circle Programming Logic and Design, Introductory, Fourth Edition

Slide 27

Using the Priming Read (kept) Priming read sets up the procedure so the circle can be organized To break down a flowchart\'s structure, have a go at composing pseudocode for it Programming Logic and Design, Introductory, Fourth Edition

Slide 28

Using the Priming Read (proceeded) What isn\'t right with this configuration? Programming Logic and Design, Introductory, Fourth Edition

Slide 29

Understanding the Reasons for Structure Advantages of structure: Provides clarity Professionalism Efficiency Ease of upkeep Supports measured quality Programming Logic and Design, Introductory, Fourth Edition

Slide 30

Understanding the Reasons for Structure (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 31

Understanding the Reasons for Structure (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 32

Recognizing Structure Any arrangement of guidelines can be communicated in organized organization Is this flowchart organized? Programming Logic and Design, Introductory, Fourth Edition

Slide 33

Recognizing Structure (proceeded) Is this flowchart organized? Programming Logic and Design, Introductory, Fourth Edition

Slide 34

Recognizing Structure (proceeded) To make it organized, haul every image out and revamp B starts a determination structure Programming Logic and Design, Introductory, Fourth Edition

Slide 35

Recognizing Structure (proceeded with) Pull up on the flowline from the left half of B Programming Logic and Design, Introductory, Fourth Edition

Slide 36

Recognizing Structure (proceeded) Next, draw up the flowline on the right half of B Programming Logic and Design, Introductory, Fourth Edition

Slide 37

Recognizing Structure (proceeded with) Pull up the flowline on the left half of D and unwind it from the B choice by rehashing C Programming Logic and Design, Introductory, Fourth Edition

Slide 38

Recognizing Structure (proceeded with) Now pull up the flowline on the right half of D Programming Logic and Design, Introductory, Fourth Edition

Slide 39

Recognizing Structure (kept) Bring together the last details of D and of B Programming Logic and Design, Introductory, Fourth Edition

Slide 40

Three Special Structures – Case , Do While , and Do Until Many dialects permit three extra structures: case structure do-while structure do-until structure Case Structure: Decisions with more than two choices Tests a variable against a progression of qualities and makes a move in light of a match Nested if-then-else explanations will do what a case structure does Programming Logic and Design, Introductory, Fourth Edition

Slide 41

Three Special Structures – Case , Do While , and Do Until (kept) Using settled if-then-else for various choices Programming Logic and Design, Introductory, Fourth Edition

Slide 42

Three Special Structures – Case , Do While , and Do Until (kept) Using a case structure for numerous options Programming Logic and Design, Introductory, Fourth Edition

Slide 43

Three Special Structures – Case , Do While , and Do Until (proceeded) do-while and do-until circles Question is solicited toward the end from the circle structure Ensures that the circle articulations are constantly utilized at any rate once Programming Logic and Design, Introductory, Fourth Edition

Slide 44

Three Special Structures – Case , Do While , and Do Until (proceeded) do-while circle executes the length of the inquiry\'s answer is Yes or True do-until circle executes the length of the inquiry\'s answer is No or False (until it gets to be Yes or True) Programming Logic and Design, Introductory, Fourth Edition

Slide 45

Three Special Structures – Case , Do While , and Do Until (proceeded) while circle with inquiry at starting is known as a pretest circle do-while and do-until with inquiry at end are called posttest circles A posttest circle can be supplanted with a succession took after by a pretest while circle Programming Logic and Design, Introductory, Fourth Edition

Slide 46

Three Special Structures – Case , Do While , and Do Until (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 47

Three Special Structures – Case , Do While , and Do Until (kept) Programming Logic and Design, Introductory, Fourth Edition

Slide 48

Three Special Structures – Case , Do While , and Do Until (proceeded with) How would this be able to outline be made organized? Programming Logic and Design, Introductory, Fourth Edition

Recommended
View more...