Lecture12.6 - 1 12/12/06 From materials Copyright N. Ramsey...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 12/12/06 From materials Copyright N. Ramsey & al. 1 DPL-12: Smalltalk & OO Programming Object Orientation Basic Ideas: data abstraction (may or may not hide information) inheritance (reuse of implementations) subtyping (reuse of interfaces - "protocols") (disciplined) dynamic binding of functions Key goal: REUSE . Languages: Simula (1967); Smalltalk (1980); LISP Flavors, Loops, CLOS; C++, Objective C, C#; Eiffel, OWL; Postscript in NeWS; Modula-3, Oberon, Ada 95; Python, Java The language fad of the 90s 12/12/06 From materials Copyright N. Ramsey & al. 2 DPL-12: Smalltalk & OO Programming Terminology CLU Smalltalk Idea Cluster Class Encapsulate Data Instance Object Value Function Method Operation on ADT Function Name Message Identify Operation Function Application Message Send Invocation Rep Instance Variables State ("elds") Cluster Operations Protocol Valid Messages- Class Variables per-class State 12/12/06 From materials Copyright N. Ramsey & al. 3 DPL-12: Smalltalk & OO Programming Terminology A class associates data ( instance variables ) with code ( methods ). An object is an executable instance of a class Delegation : a method calls some other method to perform a function (e.g., implementing sets in terms of lists). Inheritance : a class reuses parts of code or data representation from another class (reusing code for drawing convex polygons to draw rectangles). Class methods do not directly affect instance variables (new). Class variables : shared by all objects instantiated from the class (used by class methods, or containing values of interest to all objects). 12/12/06 From materials Copyright N. Ramsey & al. 4 DPL-12: Smalltalk & OO Programming Smalltalk Pure object-oriented language: Everything is an object Even values like true , false , 3 , 92 , etc Classes are objects There are no functions- only methods on objects Limited control structures: message passing sequential execution (Full Smalltalk also has "nonlocal return" - exceptions in other languages) Smalltalk does not have if or while- they are simulated with objects. 12/12/06 From materials Copyright N. Ramsey & al. 5 DPL-12: Smalltalk & OO Programming Abstract Syntax datatype exp = VAR of name | SET of name * exp | BEGIN of exp list | SEND of name * exp * exp list | BLOCK of name list * exp | LITERAL of rep VAR , SET and BEGIN as in Impcore; SEND is message passing: Method is specied by name Always sent to a receiver Optional arguments BLOCK and LITERAL are special objects. 12/12/06 From materials Copyright N. Ramsey & al. 6 DPL-12: Smalltalk & OO Programming Concrete Syntax exp ::= literal | variable-name | (set variable-name exp ) | (begin { exp }) | ( message-name exp { exp }) | (block ({a rgument-name }) { exp }) | [{ exp }] literal ::= integer-literal | # name | #({ array-element }) array-element ::= integer-literal | name | ({ array-element }) 2 12/12/06 From materials Copyright N....
View Full Document

This note was uploaded on 02/13/2012 for the course CS 91.531 taught by Professor Giam during the Fall '09 term at UMass Lowell.

Page1 / 14

Lecture12.6 - 1 12/12/06 From materials Copyright N. Ramsey...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online