Classes, Objects, and World-level Methods

Slides:



Advertisements
Similar presentations
CS320n –Visual Programming Class-level Methods and Inheritance – Part 1 Mike Scott (Slides 4-3-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger.
Advertisements

Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
CSC1401 Animation Creating methods/instructions (class-level)
Alice Methods and Classes. Methods and Classes Methods – Coordinated sequence of instructions carried out when requested (e.g. move, turn to, etc.) Class.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
World-level Methods with Parameters Alice. Larger Programs As you become more skilled in writing programs, you will find that your programs quickly begin.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Alice: A Visual Introduction to Programming Chapter 1 Part 2.
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
Fall 2008ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Classes, Objects, and World-level Methods
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Classes, Objects, and World-level Methods Section 47 Web Design.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Class-level Methods Chapter 6 part 1. Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Alice: A Visual Introduction to Programming Chapter 1 Part 2.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
CompSci 4 Chap 4 Sec 1 Sept 15, 2005 Prof. Susan Rodger.
CS320n –Visual Programming Classes, Objects, and World- Level Methods Mike Scott (Slides 4-1)
Classes, Objects, and World-level Methods MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Object Oriented Programming Some Interesting Genes.
AP CSP: Creating Functions & Top-Down Design
Classes, Objects, and World-level Methods
OOP - Object Oriented Programming
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
Object-Orientated Programming
Classes, Objects, and World-level Methods
Teaching Characters to Walk: Learning Methods, Part 1
Classes, Objects, and World-level Methods
Classes, Objects, and World-level Methods
World-level Methods with Parameters
Procedural Abstraction Object-Oriented Code
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
CS320n –Visual Programming
Inheritance Basics Programming with Inheritance
Classes, Objects, and World-level Methods
Class-level Methods Alice.
Classes, Objects, and World-level Methods
Making Procedural Methods
Programming Basics - RobotC
Tonga Institute of Higher Education
Design and Implementation
Computer Programming with JAVA
Introduction to Object-Oriented Programming in Alice
Classes / Objects / Methods
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Computational Thinking
Use Case Analysis – continued
Classes, Objects, and World-level Methods
Class-level Methods and Inheritance
Week 1 - Friday COMP 1600.
Presentation transcript:

Classes, Objects, and World-level Methods Alice

Larger Programs Complex programs require many lines of code (LOC) Games, movies: 1000s or millions of LOC How to handle such large programs? Break up into smaller, manageable pieces

Can’t see all the code even for our example from last class!

Classes, Objects, & Methods Object-oriented programming (OOP): program consists of objects acting on each other each object is an “actor” with its own role OOP helps to organize programs into small modules ease the design process make code reusable find and remove errors (bugs) One object acts on another by calling the other objects methods. Another way to think of this is that one object is "sending a message" to the other object. For example, a "Driver" object might send a message to a "Car" object to turn right. Named messages correspond to named methods and functions in a class definition.

Class vs. Object Class: Object: a conceptual framework for an entity describes properties, methods, functions cannot be used directly in execution Object: a realization of a class in a program instance of used directly during execution A class is like a blueprint for creating a specific kind of object. Even better, it is like a factory for creating a certain type of objects. Objects are specific instances of classes that have been created for use in a particular program. The first object created in a program from a class has the same name as the Class, which can be a little confusing. But if you create multiple objects from the same class, they will automatically receive unique names, like Ambulance2, etc.

Class vs. Object class Person beth derek maria pete … objects Don't confuse classes with the groupings Alice uses to display related objects. Since there is no "Person" class in Alice, a better example might be something like using the "RandomGirl" class to create instances named Beth, Maria, Susan, etc. objects

More Specifics height weight eye color talk walk twiddle thumbs Person properties methods height weight eye color talk walk twiddle thumbs Person 6’ 3” 285 lbs. dreamy blue 6’ 0” 175 lbs. exotic green derek prof. L

In our programs, we have been using… Classes In Alice, classes are predefined as 3D models Objects An object is an instance of a class. Class: Frog (Uppercase name) Objects: frog, frog1, frog2, frog3 (lowercase names) Using lower case names for objects isn't consistent across all classes supplied with Alice, but it is a nice way of distinguishing between the Class that generates an object and the objects it generates.

We have also used… Built-in (predefined) methods World.my first method Examples: move, turn to face, say World.my first method provided automatically by Alice started when you press the “run” button we have written all code in this method What about writing other methods?

Solution to One Long Method Organize instructions into separate smaller methods Stepwise refinement: break a problem into large tasks then break each task into simpler steps

Chicken Baseball

Chicken Baseball Large tasks: Don’t worry about details at this level chicken swings chicken runs chicken slides chicken throws chicken catches Don’t worry about details at this level abstraction

Chicken Runs This will be its own method Consider details: turn to face a base in a loop, do together: move 0.5 meters forward turn legs forward/backward

Why? Why write our own methods? saves time: call the method again and again reduces code size: no need to write the instructions again and again allows us to "think at a higher level" can think chicken run instead of “The chicken turns to face the base, then loop doing… ” easier to find bugs

Creating a new method First, to associate the new method with the World select the World tile in the Object Tree select the methods tab in the details area click on the "create new method" button