Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods.

Similar presentations


Presentation on theme: "Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods."— Presentation transcript:

1 Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods

2 Chapter 4.1 Learning Goal: Technical analysis and communication skills – Tutors help you “ask yourselves the right questions”

3 What do you get from this course? Analysis skills – – Practiced and refined in your group discussions! We learned in Alice that computers do exactly what you have them do. Using this knowledge, we can understand how programs like Excel and Numbers work and learn that when we are using these programs, we need to specify and be exact with what we are doing in order for the programs to meet our needs and plans.

4 Clicker Discussion Analysis Technique: Begin at the beginning: – Are you reading the question the “same way”? – What is the question asking for? TRY THESE: – “So what I think this is asking is” – “It seems like the idea here is whether we can identify the differences in these codes” – “We need to figure out how to correct this code to do X instead of Y”

5 What is the best explanation of why we divide code into methods? A.In order to be able to put a name on them B.In order to break work into manageable pieces C.So it can be stored more efficiently D.So that each object can have “actions” they do

6 What term do we use to describe the indicated area below A. Method call B. Method definition

7 When you hit Play Alice will by default*: A.Runs World.My first method B.Starts by running whatever method you created first C.Starts by running whatever method you created last D.Runs all the methods in the order they appear in the methods tab E.None of the above *Assuming you don’t modify any of the events in the upper right corner

8

9 The First Encounter World In chapter 2 you developed the first encounter world and created the following code…

10

11 Step-wise refinement Break the work up into three methods – Call those methods from my first method

12 One should use methods in programs primarily… A.For the computer B.For the person writing the program C.For people reading a program D.More than one of the above And WHY is it important?

13 How to “make” methods Think of ways in which your planned animation has natural “parts” – Give each of the parts a name – Put the code that makes that “part” happen in a method with that name – Call that method from my first method, in the right order.

14 Example: Going to a movie… Walk up to ticket window – Walking in group Buy tickets – Interact with ticket seller (talking, hand over money, get tickets) Enter theater – Walk through doors, hand tickets to worker, walk into lobby Buy snacks… Take seats… Make snarky critiques… …

15 Below shows an example of the benefits of using methods because it allows the programmer to… A.Comment methods to further explain what they do B.Re-order the parts of the animation with little extra work C.Repeat a set of instructions with little extra work

16 Below: what happens after the last instruction in the mystery method is finished executing? A.The program starts the World.my first method B.The program goes back to my first method and calls method XXXXX C.The program goes back to my first method and calls method YYYYY D.We can’t tell, we need to know more about the storyboard to be able to say

17 Methods: Why again? Break complex things into smaller, more manageable pieces (step-wise refinement) – Do something more than once… Do something more than once, but not exactly the same each time – Parameters allow you to write code one time but have it be useful in various circumstances where the “thing” involved could be different each time


Download ppt "Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods."

Similar presentations


Ads by Google