OOPS - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

OOPS

Description:

Sometimes classes can share some of the same attributes and protocols. ... can respond to, but also has one further attribute and additional protocols. ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 21
Provided by: hop54
Category:
Tags: oops | attribute

less

Transcript and Presenter's Notes

Title: OOPS


1
OOPS
  • Object-Oriented Programming in Smalltalk

2
Practical Sessions 1-5
  • These sessions introduce you to the Smalltalk
    Environment, and use the familiar idea of
    PieEater to examine a number of important
    concepts.
  • The Environments are there for you to explore,
    and to ensure that you have understood the basic
    ideas.
  • The most important of these ideas are summarised
    in this lecture.

3
Practical Session 1
  • Practical Session 1 introduces you to a new
    environment, and some new PieEaters.

4
Practical Session 2
5
Practical Session 1
  • What you should Learn
  • Each of the PieEaters is an Object, to which we
    can send messages.
  • We can inspect the state of each object
  • Messages to objects maybe via buttons or Text,
    and take the form
  • Receiver ltMessagegt (e.g. Pie1 Walk)
  • All objects in the same class have the same
    attributes and respond in the same way to each
    message.

6
Representing Objects
 
  • This is an object diagram for an object from the
    PieEater Class
  • It shows
  • class
  • attributes
  • messages that can be understood

 
7
Protocol
  • The Protocol of an object is simply the set of
    messages that an object can understand, together
    with the effects of those messages
  • message
  • home
  • left
  • effect
  • receiver moves to position 1
  • reduces position value by 1

8
Practical Session 2
  • This session introduces you to a new class of
    object- PastieEater
  • This has a different start position and colour

9
Practical Session 2
10
Practical Session 2
  • What you should learn
  • Objects belonging to different classes will have
    some attributes and/or protocols different.
  • Sometimes classes can share some of the same
    attributes and protocols. This is called
    Polymorphism.

11
Practical Session 3
  • This introduces you to a new object called
    FlashPieEater
  • This object can respond to all the messages that
    PieEater can respond to, but also has one further
    attribute and additional protocols.

12
Practical Session 3
13
Practical Session 3
  • What you should learn
  • Subclasses of objects are objects which have all
    the attributes of the original class
    (superclass), but have additional attributes (and
    protocol)
  • We can construct Class Hierarchy Diagrams

14
Practical Session 4
  • Session 4 introduces the idea of message
    arguments.
  • This is achieved in this case by a colour ...
    widget
  • widget device
  • Note that green and red are commands which have
    been programmed but there are no commands to
    change the colour to blue, for example.

15
Practical Session 4
16
Practical Session 4
  • What you should learn
  • Messages to objects may sometimes require an
    argument to be given.
  • For example the message
  • Pie5 colour ClrBlack
  • will send a message to Pie5 to change its colour
    to black.
  • These messages can be programmed into widgets

17
Practical Session 5
  • In this session we look at different ways of
    communicating with objects.
  • There is a new widget
  • and a message reply box, for the objects
    response,

18
Practical Session 5
19
Practical Session 5
  • What you should learn
  • All messages to objects return information
    (whether you want it or not)
  • The message usually is a description of the state
    of the object after it has completed the action.
  • We can interrogate objects as to their state, and
    we can use this idea to get objects to
    collaborate, by asking one to interrogate
    another, and act on the outcome.

20
SameColourAs collaboration
Pie1
Pie2
User
  • sameColourAs Pie2
  • colour
  • ClrGreen
  • colour ClrGreen
Write a Comment
User Comments (0)
About PowerShow.com