Principles of Object-oriented Programming - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Principles of Object-oriented Programming

Description:

Squeak compiler and VM written in Squeak. ... The Muppet class refers to the set of all muppets. ... This creates a class hierarchy in which subclasses take on ... – PowerPoint PPT presentation

Number of Views:345
Avg rating:3.0/5.0
Slides: 16
Provided by: chrisb2
Category:

less

Transcript and Presenter's Notes

Title: Principles of Object-oriented Programming


1
Principles of Object-oriented Programming
  • Programming Language Paradigms
  • August 26, 2002

2
Pre-history
  • 40s/50s von Neumann architecture, stored
    program concept
  • Allows the development of general-purpose
    computing machines
  • Languages tend to be closely tied to the
    underlying architecture
  • Structured programming emerges
  • Verb and task oriented
  • Difficult to scale

3
History
  • Simula-67 objects, early GUI elements
  • Xerox PARC (70s) Smalltalk, bitmap displays,
    multiple windows, mouse, menus, icons, etc.
  • Smalltalk-80 modern version
  • released outside PARC.
  • Used a virtual machine and a bytecode compiler.
  • Spinoff companies create commercial versions.

4
Squeak History
  • 1995 (Apple) Alan Kay et al. create an
    open-source version of Smalltalk.
  • Development of a platform that can be used by
    people of all ages and skill levels.
  • Squeak compiler and VM written in Squeak.
  • Support for sound, 2-D and 3-D graphics,
    networking/web, Flash, etc.

5
Other OO history
  • C developed at ATT labs (Stroustrup79)
  • Interested in an efficient language that extended
    C
  • Strong typing
  • Objective C
  • Used in NeXT and OS X combination of C and
    Smalltalk.
  • Java developed by Sun (1991-1995)
  • Initially developed as a language for
    communicating appliances/set-tops
  • Modified for use with WWW.
  • Smalltalk features in a typed environment

6
About Objects
  • An object is a way to capture both the features
    of a data structure and its behavior.
  • Noun-oriented encourages program design through
    thinking about pieces
  • Construction of reusable elements

7
Classes and objects
  • A class is a characterization of a type of
    object.
  • The Muppet class refers to the set of all
    muppets.
  • An object kermit is an instantiation of the
    Muppet class.
  • Classes have
  • Instance variables
  • Class variables
  • methods

8
An example
  • Object subclass Muppet
  • instanceVariableNames name
  • classVariableNames numberOfSpecies
  • category muppets
  • To create a muppet
  • Kermit lt- Muppet new.

9
Messages
  • In Smalltalk, methods are invoked by sending the
    object a message.
  • noun verb arg1 mod arg2 .
  • Modeled on speech acts.

10
Inheritance
  • One of the most popular OO features is
    inheritance.
  • Can define new classes in terms of existing
    classes.
  • This creates a class hierarchy in which
    subclasses take on the behavior of their parent
    classes.
  • A subclass can generate new behaviors by
  • Defining new methods
  • Overriding a parent method.

11
Inheritance example
12
Polymorphism
  • Polymorphism is the idea that an object or method
    can perform the same operation on different data
    types.
  • Addition is polymorphic in most languages.
  • Allows a programmer to write code without knowing
    the types of the data involved.
  • listOfStuff sort lt- dont need to know what
    this is a list of.

13
Polymorphism example
14
Encapsulation
  • Encapsulation provides a way of packing all the
    structure and behavior of an object into a single
    module.
  • Interface the public face of an object
  • Implementation How methods are carried out.
  • Prevents users from misusing internal structure.
  • Implementation can be changed without affecting
    external programs.

15
Encapsulation example
Write a Comment
User Comments (0)
About PowerShow.com