Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Computers Can’t Cook! Programming Methodology Girls Engaged in Math and Science, June 2012 Bri Chapman.

Similar presentations


Presentation on theme: "1 Computers Can’t Cook! Programming Methodology Girls Engaged in Math and Science, June 2012 Bri Chapman."— Presentation transcript:

1 1 Computers Can’t Cook! Programming Methodology Girls Engaged in Math and Science, June 2012 Bri Chapman

2 2 What is programming methodology? deals with how programs are written is a way of thinking about difficult problems that can help break a problem into manageable chunks helps programmers think more clearly when they are writing programs.

3 3 Who wants cookies? Here is my favorite cookie recipe: Bri’s Famous Chocolate Chip Cookies Ingredients: WET: DRY: 3 eggs, room temperature 5 cups flour 3 teaspoons vanilla extract 2.5 cups brown sugar 4 sticks unsalted butter 4 cups chocolate chips 4 tablespoons milk 2 teaspoons salt 1 cup white sugar Mix up all the ingredients in the normal way and then put the cookies in the oven and bake them at 375º F.

4 4 What is the normal way? Computers don’t know anything about baking. While I may know what the “normal way” is -- with a mixer set to a certain speed and a spatula-- a computer doesn’t. I like to eat cookies but I don’t want to bake them from now on. I need to teach my computer what the “normal way” is.

5 5 Using programming methodology to explain the “normal way” What I want my computer to do is mix the ingredients. Here is the program I will write: computer start; mix (ingredients); computer end; Will this work?

6 6 Not yet. I need to tell the computer what “mix (ingredients);” means. computer start; mix (ingredients); computer end; method mix (ingredients): { grab spatula; set up mixer; put ingredients in bowl; turn on mixer; mix until smooth; turn off mixer; }

7 7 Will it work yet? Not quite yet. The computer still doesn’t know how to do most of these things. We must keep defining these methods until we come to something the robot or computer understands how to do already.

8 8 computer start; mix (ingredients); computer end; method mix (ingredients): { grab spatula; set up mixer; put ingredients in bowl; turn on mixer; mix until smooth; turn off mixer; } Here is our program so far: Let’s define “put ingredients in bowl;” method put ingredients in bowl: { soften butter; put in (butter); crack eggs; put in (eggs) put in (vanilla); put in (milk); cream (wet ingredients); put in (white sugar); put in (brown sugar); put in (salt); put in (baking soda); put in (flour); }

9 9 Can we reuse methods? Since the computer doesn’t know what we mean when we say “put in (eggs),” or “put in (flour)” we will need to explain what we mean. There are parts of the process of putting in eggs and putting in flour that are the same-- the part where we dump stuff in the mixer. There are also parts that are different. What is the same and what is different?

10 10 Let’s define a method “put in();” method put in(): { pick up item; move until item is above bowl; rotate 180º vertically; wait 5 seconds; rotate 180º vertically; set cup down; }

11 Now, let’s use the new method: computer start; mix (ingredients); computer end; method mix (ingredients): { grab spatula; set up mixer; put stuff in bowl; turn on mixer; mix until smooth; turn off mixer; } put stuff in bowl { soften butter; put in (butter); crack eggs; put in (vanilla); put in (milk); cream (wet ingredients); put in (white sugar); put in (brown sugar); put in (salt); put in (baking soda); put in (flour); } method crack eggs { count 3 eggs; repeat 3 times { break shell; drain egg; put in (eggs); } method put in (): { pick up item; move until { item is above bowl } rotate 180º vertically; wait 5 seconds; rotate 180º vertically; set cup down; }

12 12 Are computers like humans? Sometimes. What is a method? A method is a set of instructions, telling the computer what to do. When a computer sees a method it doesn’t know, it searches through the rest of the program to see if there is a definition, just like when humans see a word we don’t know, we search through a dictionary to find its definition!

13 Let’s work on finishing the program! We will break up into groups and each group will be assigned one of the methods we have not defined yet. You will then work on defining it, breaking it down into smaller and smaller pieces until you get to something you think the computer should understand, like “rotate 180º,” or “move 5 inches.” Feel free to reuse methods we have written already. If you finish early, write a method for baking the cookies using programming methodology. If time allows, when everyone has finished, we will have a volunteer from each group present their program to the class and explain their thought process. Choices are: “grab spatula;” “set up mixer;” “turn on mixer;” “mix until smooth;” and “turn off mixer”

14 Feel free to reuse methods we have already written: computer start; mix (ingredients); computer end; method mix (ingredients): { grab spatula; set up mixer; put stuff in bowl; turn on mixer; mix until smooth; turn off mixer; } put stuff in bowl { soften butter; put in (butter); crack eggs; put in (vanilla); put in (milk); cream (wet ingredients); put in (white sugar); put in (brown sugar); put in (salt); put in (baking soda); put in (flour); } method crack eggs { count 3 eggs; repeat 3 times { break shell; drain egg; put in (eggs); } method put in (): { pick up item; move until { item is above bowl } rotate 180º vertically; wait 5 seconds; rotate 180º vertically; set cup down; }

15 15 What problems did you have? What was difficult about using programming methodology to break down the problem of explaining how to make cookies to a computer? Do you think it would have been easier or harder to just write the program without breaking it down step by step? Why do you think programmers use programming methodology?

16 More information Stanford University offers a course available through iTunes University called CS 106 A. All the course materials are available online for free. The course is taught by Mehran Sahami, who is an extremely engaging professor. If you watch these lectures, you will learn the Java programming language, which is used to program applications for Android smartphones, as well as computer applications. http://tiny.cc/5rxffw


Download ppt "1 Computers Can’t Cook! Programming Methodology Girls Engaged in Math and Science, June 2012 Bri Chapman."

Similar presentations


Ads by Google