Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Software Development 1Slide 1 Artwork: An introduction to programming primitives Draw a picture [1 minute]Draw a picture [1 minute] –It.

Similar presentations


Presentation on theme: "Fundamentals of Software Development 1Slide 1 Artwork: An introduction to programming primitives Draw a picture [1 minute]Draw a picture [1 minute] –It."— Presentation transcript:

1 Fundamentals of Software Development 1Slide 1 Artwork: An introduction to programming primitives Draw a picture [1 minute]Draw a picture [1 minute] –It can be concrete, abstract, whatever you want. –Don’t show it to anyone yet. You will show it later. Find a partner far away from you & sit together [1 minute]Find a partner far away from you & sit together [1 minute] Each A and B (partners), do this:Each A and B (partners), do this: –A: Without showing B your picture, tell B how to replicate the picture exactly. –B: Following A’s instructions, draw the picture. After 2 to 3 minutes, compare the original and the copy.After 2 to 3 minutes, compare the original and the copy. Repeat, with A and B reversed.Repeat, with A and B reversed.

2 Fundamentals of Software Development 1Slide 2 Artwork – Observations Class discussion:Class discussion: –What are your observations from this exercise? Your observations may include:Your observations may include: –Giving adequate instructions is hard! –Good instructions must be precise. –The instructions can be executed more than once. The 2 nd execution may yield the same picture as the 1 st.The 2 nd execution may yield the same picture as the 1 st. Or perhaps not, if the instructions interact with the environment:Or perhaps not, if the instructions interact with the environment: –perhaps you use a different pencil –perhaps you had too much coffee and your hand starts shaking. –These are all characteristics of computer programs, too!

3 Fundamentals of Software Development 1Slide 3 What is a Program? A program is a set of instructions that a computer can follow, one by one.A program is a set of instructions that a computer can follow, one by one. –If the computer knows how to do the instruction, the computer simply carries out the instruction. –If there is an instruction that the computer does not know how to do, the instruction needs to be rewritten in more detail. These are called high-level instructions.These are called high-level instructions. Exercise: What are some high-level instructions from the copy-my-picture exercise?Exercise: What are some high-level instructions from the copy-my-picture exercise? –See the next slide for some answers.

4 Fundamentals of Software Development 1Slide 4 High-Level Instructions Suppose the picture is a picture of a person.Suppose the picture is a picture of a person. –Draw the face is a high-level instruction. How can it be rewritten? –Draw the face might become: Draw the outline of the face. Draw two eyes. Draw eyebrows. Draw the nose. Draw the mouth.Draw the outline of the face. Draw two eyes. Draw eyebrows. Draw the nose. Draw the mouth. These are high-level instructions too! How might draw two eyes be rewritten?These are high-level instructions too! How might draw two eyes be rewritten? –Draw two eyes might become: Draw one eye near the top left of the outline. Draw the other eye near the top right of the outline.Draw one eye near the top left of the outline. Draw the other eye near the top right of the outline. How might draw one eye be rewritten?How might draw one eye be rewritten?

5 Fundamentals of Software Development 1Slide 5 Designing a Program, Part 1 These high-level instructions show that you can use top-down design to build programs like the copy- my-picture program.These high-level instructions show that you can use top-down design to build programs like the copy- my-picture program. Step 1:Step 1: –Ask yourself “What do I do next?” –until you have a sequence of instructions that accomplishes the desired result. Step 2:Step 2: –Ask yourself “How do I do each of these things?” –until each instruction is something the computer knows how to do.

6 Fundamentals of Software Development 1Slide 6 Programming Primitives We call the things that the computer knows how to do programming primitives.We call the things that the computer knows how to do programming primitives. What general-purpose programming primitives did you use in the draw-my-face exercise?What general-purpose programming primitives did you use in the draw-my-face exercise? Most computer languages provide:Most computer languages provide: –Combining by sequencing: do this, then that, then... –Combining by grouping and giving the group a name (high-level instructions). This is called procedural abstraction (aka encapsulating in methods)This is called procedural abstraction (aka encapsulating in methods) –Loops E.g. (for drawing a circle): Repeat 360 times: draw a short line and change direction by 1 degree.E.g. (for drawing a circle): Repeat 360 times: draw a short line and change direction by 1 degree. –Conditionals E.g.: If you have finished the circle, stop; else...E.g.: If you have finished the circle, stop; else...

7 Fundamentals of Software Development 1Slide 7 Summary, so far A programmer answers the questions:A programmer answers the questions: –What do I do next? –How do I do each of these things? Programming primitives include:Programming primitives include: –Sequencing, procedural abstraction, conditionals, loops. This is only one part of the programming problem. The second part is:This is only one part of the programming problem. The second part is: Coordinating the activities of many interdependent participants in a computational community


Download ppt "Fundamentals of Software Development 1Slide 1 Artwork: An introduction to programming primitives Draw a picture [1 minute]Draw a picture [1 minute] –It."

Similar presentations


Ads by Google