lecture 5: finishing 4.3 and onto 5.1

27
Lecture 5: Finishing 4.3 and onto 5.1 • Preparing for the Midterm: Written Explanations • Technology and Society Assignment (5% - 3 in term) – How does the internet work? You can figure it out! – Due Wednesday Week 4 – See moodle (let’s look) • Thursday Office Hours Moved this week – 1-2pm

Upload: wayne

Post on 24-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

Lecture 5: Finishing 4.3 and onto 5.1. Preparing for the Midterm: Written Explanations Technology and Society Assignment (5% - 3 in term) How does the internet work? You can figure it out! Due Wednesday Week 4 See moodle (let’s look) Thursday Office Hours Moved this week 1-2pm. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lecture 5:  Finishing  4.3  and onto  5.1

Lecture 5: Finishing 4.3 and onto 5.1

• Preparing for the Midterm: Written Explanations• Technology and Society Assignment (5% - 3 in

term)– How does the internet work? You can figure it out!– Due Wednesday Week 4– See moodle (let’s look)

• Thursday Office Hours Moved this week– 1-2pm

Page 2: Lecture 5:  Finishing  4.3  and onto  5.1

Group Discussion:Practice for the “Real World”!

• Discussion on the exam?– Written explanations of multiple choice question

answers• Remember the eskimoGirl jumping and

saying Hello?

Page 3: Lecture 5:  Finishing  4.3  and onto  5.1

How would we change the code to make her say

Hello while jumping up and

down?

Page 4: Lecture 5:  Finishing  4.3  and onto  5.1

What makes a good explanation?

• Shows English expression of understanding – not just reading what the code does.

• Uses appropriate terminology (DoTogether, method, etc.)

• Explains why incorrect answers are wrong.

Page 5: Lecture 5:  Finishing  4.3  and onto  5.1

Good explanations: Clear understanding of how the code performs

• We need things to happen simultaneously so we’ll use a DoTogether tile. However, if we want the eskimoGirl to jump up then down, we need a DoInOrder tile within the DoTogether tile. Without a DoInOrder tile, the methods move up and move down will occur at the same time, causing the eskimoGirl to do nothing.

Page 6: Lecture 5:  Finishing  4.3  and onto  5.1

Good explanations: Summary plus option comparison

• D) None of the above. The storyboard we want is an eskimoGirl jumping up and down WHILE saying hello.

• In option A), the girl says hello first, then jumps up and down.

• In option B), the girl jumps up, then says hello as she comes down.

• In option C) it would be correct except the eskimoGirl moves down then up.

• The correct answer is like C – with a DoTogether tile with the say hello happening together with “jumping” – which we implement with a DoInOrder tile with move up then move down

Page 7: Lecture 5:  Finishing  4.3  and onto  5.1

Which of the following is the best definition of a class-level method?

A. A method that controls an ice-skaterB. A method that belongs to a particular objectC. A method that takes parameters to control

how it worksD. A method that you need to be sure to save in

order to be able to use it in the future

Page 8: Lecture 5:  Finishing  4.3  and onto  5.1

The somewhat complex steps of having a skater spin around were managed by what technique:

A. Use of parameters to control the actionB. Stepwise-refinement to create multiple levels

of methodsC. Class-level methods to support development

of a new cleverSkater classD. Use of primitive methods pre-built into the

Alice software

Page 9: Lecture 5:  Finishing  4.3  and onto  5.1

What are the correct names for the underlined terms?

1 2A Calling Object ParameterB Parameter Calling object

Page 10: Lecture 5:  Finishing  4.3  and onto  5.1

The area indicated below contains what?

A. My First Method because that’s what is always done first

B. An event -- a mouse click or key pressC. An event handler methodD. A parameter

Page 11: Lecture 5:  Finishing  4.3  and onto  5.1

Building my OWN flight simulator:What will the plane do when the right arrow button is pushed?

A. Turn leftB. Turn rightC. Alice will complain that there is a logic errorD. I don’t know

Page 12: Lecture 5:  Finishing  4.3  and onto  5.1

Parameterization: Changing from specific to more general

• sayHelloToAlien -> sayHelloTo– Made the object of “who” we want to say hello to

a parameter• sayHelloTo -> sayTo– Add a 2nd parameter to make even more useful in

more situations• Maybe you don’t ALWAYS want to say hello!

Page 13: Lecture 5:  Finishing  4.3  and onto  5.1

Parameterization Done!

• Very specific class-level method with no parameters– Class-level – owned by talkativeSpiderRobot class– An action that applies to talkativeSpidertRobots

• Added 2 parameters to make it more flexible/control how it behaves– Object: Who to talk to– String: What to say

• Next: Deeper analysis of things people get confused about with class-level methods

Page 14: Lecture 5:  Finishing  4.3  and onto  5.1

EXAM PREP:Which of the following is the best explanation of

what makes a good parameterA. It’s something that supports common

variation in how the method is doneB. It’s got a meaningful nameC. It can be either an Object or a numberD. It helps manage complexity in large programs

Page 15: Lecture 5:  Finishing  4.3  and onto  5.1

Suppose we have the following world with 2 objects of the talkativeSpiderRobot class

What code will make this happen?

Page 16: Lecture 5:  Finishing  4.3  and onto  5.1

Which method call will make this happen? (play animation)

C) Both of those method calls do that same thing

Page 17: Lecture 5:  Finishing  4.3  and onto  5.1

Class-level methods (e.g. skater methods, talkativeSpiderRobot methods) cannot have an

object type parameterA. True, they have to only act on the object of the

class they belong to (e.g. skater, tSR)B. True, class level methods can’t have any

parametersC. False, they can take as parameters another

object they may interact withD. False, they must always take an object

parameter of the class they belong to (e.g. skater,tSR)

Page 18: Lecture 5:  Finishing  4.3  and onto  5.1

Small variation: Make both objects turn to face each other

Page 19: Lecture 5:  Finishing  4.3  and onto  5.1

In lab, Maria says: “What I did was I used the parameter of SayTo and made it the calling object a call to the turnToFace method”

Page 20: Lecture 5:  Finishing  4.3  and onto  5.1

Frank is trying to follow along: “Wait, you said whoTo was a parameter here, why did you call it a calling

object here?”

Page 21: Lecture 5:  Finishing  4.3  and onto  5.1

Maria says…

A. Sorry, I mis-spoke, whoTo is a parameter, and that’s what we should call it

B. Because names can depend on the context in which they are used (e.g. the sayTo method or the turnToFace method)

C. Because names are determined by location: one place it comes after the method name and in one place it comes before the method name

Page 22: Lecture 5:  Finishing  4.3  and onto  5.1

Yes, one “thing” can have two names:It depends on the CONTEXT

Page 23: Lecture 5:  Finishing  4.3  and onto  5.1

Why do we care what these things are named and why we name them different things in different places?

• After this class: calling object vs parameter– Probably not important

• What is important– Recognizing the specificity that can be critical in

communicating about technical issues– Taking care to interact effectively with others

when discussing technical issues• Especially when they are LESS or MORE familiar with

the given technology than you

Page 24: Lecture 5:  Finishing  4.3  and onto  5.1

Have you ever had an experience where miscommunication regarding a technical issue caused problems?

(maybe fixing a problem,trying to get software to work, etc.)

A. YesB. NoC. I don’t know what you are talking about

Page 25: Lecture 5:  Finishing  4.3  and onto  5.1

Opacity and Is Showing

• Properties of objects, useful for nice effects and to make things “appear” later in animations

• No existing methods in method list– Click on properties tab and drag that property

pane into program, choose a value and it will call a “set to” method on that property

– Every property can be set with a “set to” method in your program

Page 26: Lecture 5:  Finishing  4.3  and onto  5.1

Chapter 5: Interactive Worlds with Event Handling

• Instead of having “animation” controlled by a specific method (every time) – like my first method– Control can vary based on a set of possible “events”– Create an event link to a method– Multiple methods can link to same event – but perhaps

with different parameters• What code runs when you hit play?– Essentially a method “listening” for you to click or push

a button – it listens over and over again

Page 27: Lecture 5:  Finishing  4.3  and onto  5.1

Identify the parameters in the following event link

1 IceSkater

2 kick 3 iceSkater.rightLeg

4 iceSkater.rightLeg.lowerLeg.foot

A X X X XB X X XC XD X X