1 / 24

Object Oriented Programming Group

Object Oriented Programming Group. Featuring: James Webber II Topics Include: OOP Smalltalk. 3 Key language features. Abstract Data Types Requires abstraction: I don’t want to know what’s in a car that makes it work, it just needs to work with the definitions given to me

allene
Download Presentation

Object Oriented Programming Group

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Programming Group Featuring: James Webber II Topics Include: OOP Smalltalk

  2. 3 Key language features • Abstract Data Types • Requires abstraction: I don’t want to know what’s in a car that makes it work, it just needs to work with the definitions given to me • Basically unique data type defined by programmer • Inheritance • Bestow, add, or modify characteristics of an existing class by creating a subclass with the same basic characteristics • Dynamic call of method calls to methods • Basically means accessing methods of a subclass by using a base class’ pointer (aka polymorphism)

  3. Smalltalk: The First OOPL • Program consists entirely of objects & everything is treated uniformly • Messages can be parameterized with variables that reference objects • ALL objects referenced from heap and all objects are implicitly dereferenced • No explicit dereferencing: there is a garbage collection process • Smalltalk is also a pure OOPL in that all data types are objects and all operations on them are methods

  4. Inheritance • What is the point of inheritance? • Organize & Modify programs • Organize accessible data of subclasses • Modify existing data by redifining definitions of the superclass in a subclass Mammal -> primate -> human -> student -> CS student beast Remove sleep and finances Throw in intelligence Further increase intelligence at the cost of social skills and remove 30 minutes of life Increase intelligence (theoretically)

  5. Inheritance Terminology • Object: Class Instances • Method: subprograms which define operations on objects • Message: call to a method • Message protocol: entire collection of methods • Overridden method: a base class method which is redefined in a derived class

  6. An Inheritance issue • The Diamond Problem • Classes B and C both inherit from A • Class D inherits from both B and C • If method in D calls a method in A and both B and C have overriden the method, which method does D inherit? • The Diamond Solution • Different languages solve this problem in different ways

  7. Access Control: What is inherited? • Public: publicly accessible members inherited from the base class stay publicly accessible in derived class • Protected: members are not accessible from outside the class except in derived classes (they remain protected there) • Private: public and protected members of the base class are made private in the derived class C++ terminology

  8. Dynamic Binding • Polymorphic reference / pointer: when a pointer to a base class’ object has the capability to point to a derived class’ object • These are determined at run-time via the object’s type • Abstract method: a protocol that is within the body of the base class (a hollow shell) which is defined in the derived class • A class that includes at least one abstract method is called an abstract class C++ terminology

  9. Alan Kay • Designer of smalltalk • Wrote thesis on “dynabook” concept • Described laptops / tablet PCs (kind of) • Described small & portable computer • Described infinite battery life • Described purpose: teach children (target audience is not adults) • Performed studies on children • Children learn best kinetically with motion using images, symbols, abstract representation • Heavy influence on OLPC (one laptop per child) • Employed by Xerox Parc at time Smalltalk Invented

  10. Development of Smalltalk • Developed by Xerox Palo Alto Research Center employees • Most notable are Alan Kay(design) and Adele Goldberg (group leader/implementation management) • When people reference smalltalk, they normally reference the 1980 version dubbed “smalltalk-80”

  11. Smalltalk Timeline: • 1971- Kay creates smalltalk due to bet: “page of code” message passing programming language • 1971-1972- an actually researched smalltalk-72 is created • End of 1976- a development environment included (GUI) • 1980- first language made available outside of Xerox PARC • Added metaclasses (class whose instance is a class) • Apple, HP, universities called for “peer review” • Made ANSI standard in 1998

  12. Smalltalk’s Diamond solution • Recall that the diamond solution is different for every language • Inheritance can be a real pain, keeping track of multiple inheritance can be worse if there are more overriden classes like B and C • Smalltalk’s solution: let’s not deal with it… only single inheritance is allowed

  13. The Single Inheritance Life • The life of a message: • Message to object causes class to be searched for corresponding method dynamically • Search fails… go to superclass • Repeat until system superclass OBJECT • Has no superclass • If not found… ERROR! • The price of the message: • Due to this process being performed for everything dynamically (everything is an object) smalltalk programs are significantly slower than its comparable programs on different languages

  14. Classes and Inheritance • A subclass inherits all instance variables, instance methods and class methods of its super class • A subclass’ own instance variables must differ from those of superclass • if override method of superclass in a subclass then the superclass’ definition becomes hidden

  15. Smalltalk Typechecking • The only method of typechecking is ensuring that a message matches some method • Variables aren’t typed: names can be bound to any object • Variable types are irrelevant as long as they are consistent • Meaning of operation on variable determined by class of the object to which it is bound

  16. Methods, Messages, Blocks • Method: class subprogram which defines operation on object • Message: most fundamental language construct • 42 factorial “sends factorial to object 42” • 2 raisedTo: 4 “4 is argument to raisedTo and this is passed into 2” • Block: a block of code expressed as a literal value • An object that holds executable statements, what it does with the code is dependent on the context • [ :x | x+1 ] “the same as f(x)=x+1” • iftrue: [ ^somevalue]. • Iffalse:[^somevalue].

  17. Let’s Program w/ Squeak! • http://www.squeak.org/ • Supports: Windows, Mac, Linux • Also Developed by Alan Kay Remember: everything is an object and Smalltalk has limited keywords!

  18. First Thing’s First

  19. The Confusion

  20. Basic Stuff to Know

  21. Class and Inheritance Example

  22. Current Status and the Future of Smalltalk • Currently has a large following, very popular • Implemented in the OLPC as the primary OS • Multinational language support; open source SQUEAK is available for those who want to try it

  23. Conclusion • OOP • ADTs • Inheritance • Dynamic Calls to Methods • SmallTalk • First OOPL • pure OOPL • Contributed to modern GUI • Everything is an object • As a result, everything runs slowly • Order of Operations: left to right regardless (parenthesis support)

  24. References • Sebesta: OOP, Smalltalk Basics • http://en.wikipedia.org/wiki/Diamond_problem • http://en.wikipedia.org/wiki/Alan_Kay • http://www.squeak.org/ • http://gnu.paracoda.com/software/smalltalk/gst-manual/gst_34.html#SEC75 • http://www.outbacksoftware.com/smalltalk/smalltalk.html • James Webber II: Squeak Images & implementation

More Related