Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:

Similar presentations


Presentation on theme: "Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:"— Presentation transcript:

1 Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires: Classes Objects Methods World-level Class-level Parameters Inheritance

2 Fall 2007ACS-1805 Ron McFadyen2 Classes Wikipedia entry for object oriented: http://en.wikipedia.org/wiki/Object_oriented Fundamental concepts: Class Object Method Message passing Inheritance Encapsulation Abstraction Polymorphism

3 Fall 2007ACS-1805 Ron McFadyen3 Class A class defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes) and the thing's behaviors (the things it can do, i.e. methods). Object A particular instance of a class. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that's defined in the object's class. Method An object's abilities. Message passing (aside) The process by which an object sends data to another object or asks the other object to invoke a method. Fundamental OO Concepts

4 Fall 2007ACS-1805 Ron McFadyen4 Inheritance "Subclasses" are more specialized versions of a class, which inherit attributes and behaviors from their parent classes, and can introduce their own. Each subclass can alter its inherited traits. With Alice we can create new classes that are “subclasses” of others. However, if we modify the “parent” class those changes are not reflected in the subclass. Encapsulation (aside) Encapsulation conceals the functional details of a class from objects that send messages to it. This is supported by Alice, but not enforced Fundamental OO Concepts

5 Fall 2007ACS-1805 Ron McFadyen5 Abstraction Abstraction is simplifying complex reality by modeling classes and methods appropriate to the problem Polymorphism (aside) Polymorphism allows you to treat derived class members just like their parent class's members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to method calls of methods of the same name, each one according to an appropriate type-specific behavior. Not supported in Alice Fundamental OO Concepts

6 Fall 2007ACS-1805 Ron McFadyen6 4-3 Class-level methods and inheritance If we modify some object by adding properties or methods, we can then save the object as a new 3D model. Subsequently we can import the model into a world (just as we add objects from a gallery.

7 Fall 2007ACS-1805 Ron McFadyen7 4-3 Class-level methods and inheritance Text example involves the IceSkater class and the subsequent creation of the CleverSkater subclass. CleverSkater inherits all the properties, methods and functions of IceSkater and also has other methods that distinguish the subclass from the super class (aka child class… parent class). CleverSkater can then be imported into any other world where a clever skater is needed, saving the time and effort of redeveloping the code IceSkater CleverSkater

8 Fall 2007ACS-1805 Ron McFadyen8 4-3 Class-level methods and inheritance Advantages of subclassing (creating new 3d models from others): Reuse of code – write once, reuse often Simplifying large projects  many developers where each can take on a small component and then their works are brought together (imported) as needed. IceSkater CleverSkater

9 Fall 2007ACS-1805 Ron McFadyen9 4-3 Class-level methods and inheritance Guidelines: Use many class-level methods Use sound in a class-level method if the sound was imported for the object and not the world Do not call world-level methods as this creates dependencies Do not use instructions (actions, methods) for other objects as this creates dependencies (But treating them as object parameters in methods would be ok)


Download ppt "Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:"

Similar presentations


Ads by Google