UVA CS 150 - Lecture 22: Objectifying Objects

Unformatted text preview:

Slide 1Object-Oriented ProgrammingSimulaCounter in SimulaXEROX Palo Alto Research Center (PARC)Dynabook, 1972Dynabook 1972BYTE Magazine, August 1981SmalltalkCounter in SmalltalkCounter in SchemeCounter in Scheme using letWho was the first object-oriented programmer?Slide 14ChargePS6 Make an adventure game programming with objects Many objects in our game have similar properties and behaviors, so we use inheritance.PS6 ClassesPS6 ObjectsAre there class hierarchies like this in the “real world” or just in fictional worlds like Charlottansville?Microsoft Foundation ClassesSlide 21David Evanshttp://www.cs.virginia.edu/evansCS150: Computer ScienceUniversity of VirginiaComputer ScienceLecture 22: ObjectifyingObjects2Lecture 22: ObjectsObject-Oriented Programming3Lecture 22: ObjectsSimula•Considered the first “object-oriented” programming language•Language designed for simulation by Kristen Nygaard and Ole-Johan Dahl (Norway, 1962)•Had special syntax for defining classes that packages state and procedures together4Lecture 22: ObjectsCounter in Simulaclass counter; integer count; begin procedure reset(); count := 0; end; procedure next(); count := count + 1; end; integer procedure how-many(); how-many := count; end; end5Lecture 22: ObjectsXEROX Palo Alto Research Center (PARC)1970s:•Bitmapped display•Graphical User Interface –Steve Jobs paid $1M to visit and PARC, and returned to make Apple Lisa/Mac•Ethernet•First personal computer (Alto)•PostScript Printers•Object-Oriented Programming6Lecture 22: ObjectsDynabook, 1972(Just a model)“Don’t worry about what anybody else is going to do… The best way to predict the future is to invent it. Really smart people with reasonable funding can do just about anything that doesn't violate too many of Newton's Laws!”— Alan Kay, 19717Lecture 22: ObjectsDynabook 1972•Tablet computer•Intended as tool for learning•Kay wanted children to be able to program it also•Hallway argument, Kay claims you could define “the most powerful language in the world in a page of code”•Proof: Smalltalk –Scheme is as powerful, but takes two pages8Lecture 22: ObjectsBYTE Magazine, August 19819Lecture 22: ObjectsSmalltalk•Everything is an object•Objects communicate by sending and receiving messages•Objects have their own state (which may contain other objects)•How do you do 3 + 4?send the object 3 the message “+ 4”10Lecture 22: ObjectsCounter in Smalltalkclass name counter instance variable names count new count <- 0 next count <- count + 1 how-many ^ count11Lecture 22: ObjectsCounter in Scheme(define (make-ocounter) ((lambda (count) (lambda (message) (if (eq? message 'reset) (set! count 0) (if (eq? message 'next) (set! count (+ 1 count)) (if (eq? message 'how-many) count))))) 0))12Lecture 22: ObjectsCounter in Scheme using let(define (make-ocounter) (let ((count 0)) (lambda (message) (if (eq? message 'reset) (set! count 0) (if (eq? message 'next) (set! count (+ 1 count)) (if (eq? message 'how-many) count))))))13Lecture 22: ObjectsWho was the first object-oriented programmer?14Lecture 22: ObjectsBy the word operation, we mean any process which alters the mutual relation of two or more things, be this relation of what kind it may. This is the most general definition, and would include all subjects in the universe. Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine... Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent.Ada, Countess of Lovelace, around 183015Lecture 22: ObjectsCharge•Alan Kay talk at UVa!–“Children as Digital Scholars”–Wednesday, 10am–Newcomb Hall South Meeting Room•Wednesday (and PS6): –Programming with objects–Inheritance16Lecture 22: ObjectsPS6Make an adventure game programming with objectsMany objects in our game have similar properties and behaviors, so we use inheritance.17Lecture 22: ObjectsPS6 Classesobjectphysical-objectplacemobile-objectthingpersonstudentpolice-officermake-class is theprocedure for constructingobjects in the class classstudent inherits from person which inherits from mobile-objectwhich inherits from physical-objectwhich inherits from object.18Lecture 22: ObjectsPS6 Objectsobjectphysical-objectplacemobile-objectthingpersonstudentpolice-officerCabal HallRecursaAlyssa P. Hacker(make-place name)evaluates to an objectthat is an instance ofthe class place.19Lecture 22: ObjectsAre there class hierarchies like this in the “real world” or just in fictional worlds like Charlottansville?20Lecture 22: ObjectsMicrosoft Foundation ClassesCButton inherits from CWnd inherits from CObject“A button is a kind of window is a kind of object”21Lecture 22: ObjectsJava 3D Class Hierarchy Diagram http://java.sun.com/products/java-media/3D/collateral/j3dclass.htmlRotationPathInterpolatorPathInterpolatorInterpolatorBehaviorNodeLeafSceneGraphObjectNot at all uncommon to haveclass hierarchies like


View Full Document

UVA CS 150 - Lecture 22: Objectifying Objects

Documents in this Course
Objects

Objects

6 pages

Load more
Download Lecture 22: Objectifying Objects
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 22: Objectifying Objects and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 22: Objectifying Objects 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?