Objectoriented concepts - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Objectoriented concepts

Description:

A class can inherit both attributes and behaviour from one or more superclasses ... Inherited characteristics can be altered for that particular class (Polymorphism) ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 23
Provided by: CIS471
Category:

less

Transcript and Presenter's Notes

Title: Objectoriented concepts


1
Object-oriented concepts UML 1
  • LectureConcepts and ApproachesBasis of the
    Object-Oriented Paradigm

2
An Introduction to Objects
  • Basis of the Object-Oriented Paradigm

3
What are Objects?
  • A thing presented or capable of being presented
    to the senses a thing observed .. that upon
    which attention, interest or some emotion is
    fixed Chambers Dictionary
  • A tangible and/or visible thing, something that
    may be apprehended intellectually, something
    towards which thought or action is
    directedBooch

4
quite, but What are Objects?
  • Examples (of which there are many)PeopleMotor
    CarsPersonal Computersetc. etc. etc. etc.
    etc. etc. etc. ...

5
Objects Possess State
  • The state of an object encompasses all of the
    (usually static) properties of the object plus
    the current (usually dynamic) values of each of
    these properties
  • Think of state as the data possessed by an
    object
  • An object can manipulate (change, copy, delete)
    its data

6
Objects Display Behaviour
  • Behaviour is how an object acts and reacts, in
    terms of its state changes and message passing
  • Think of behaviour as an objects internal
    functions
  • Objects are responsible for instructing their own
    functions to operate and for requesting other
    objects to instruct their own functions

7
Objects Have Identity
  • Identity is that property of an object which
    distinguishes it from all other objects
  • Think of identity as being represented by an
    objects name
  • In the O-O model, all objects have completely
    unique names

8
Objects Communicate
  • Objects communicate with one another
  • This is achieved by message passing

9
Objects Have Relationships
  • LinksA physical or conceptual connection
    between objectsActors - Operates on other
    objects but is never operated
    uponServers - Only ever operated
    uponAgents - Both operates on and is operated
    upon

10
Objects Have Relationships
  • AggregationDenotes a whole/part hierarchy, for
    example

Airplane
Container
Cockpit
Wings
Container/Component
Seats
Engines
Container/Component
11
Objects Belong to Classes
  • Class and Object are tightly interwoven
  • A class is defined as a group, set or kind
    marked by common attributes or a common
    attribute a group division, distinction or
    rating based on quality, degree of competence or
    conditionWebsters Dictionary

12
ok, so What is a Class?
  • In other words, a class is a set of objects that
    share a common structure and a common behaviour
  • A single object is simply an instance of a class
  • Lets look at an exampleMammal describes a class
    of animals which possess the attributes and
    behaviours associated with being a mammal (eg.
    Cows, Monkeys, Humans etc) such as hair, suckle
    young, warm-blooded, sexual, smelly etc.

13
Class Interfaces and Implementation
  • Interfaces allow classes to provide a view of
    their internal structure and behaviour to the
    outside world
  • Implementation of a class is its internal view,
    ie. what states it possess and which behaviours
    it exhibits.

14
Class Interface Visibility
  • Public Accessible to all clientsProtected acces
    sible to itself, subclasses and its
    friendsPrivate accessible only to itself
    and its friendsIn other words
  • well formed objects must only allow friends
    to access their protected and/or private parts
    J

15
Class Relationships
  • Associations
  • Inheritance
  • Aggregation
  • Utilisation
  • Instantiation

16
Class Associations
  • Denotes a semantic dependency between classes of
    objects
  • Classes possess roles in their relationships
  • Class associations have cardinality (one-to-one,
    one-to-many, many-to-many, n-m)

17
Class Inheritance
  • A class can inherit both attributes and behaviour
    from one or more superclasses (a parent/child
    relationship)
  • Inherited characteristics can be altered for that
    particular class (Polymorphism)
  • Inheritance is hierarchical

18
Class Inheritance
A
D
B
B inherits directly from A
E
C
C inherits directly from B, therefore also
inheriting indirectly from A
E inherits directly from both A and D
19
Class Aggregations
  • Similar to the aggregation exhibited by objects
  • Whole/Part relationship (Container/Component)
  • Physical containment and containment by reference
    is possible

ShareHolder
ShareHolder is not actually constructed with
Shares but still contains them
Shares
20
Class Utilisations
  • One class acts as the Server (or Supplier) to
    another Client class

Server/Client
Server
Uses
Uses
Client
Uses
21
Class Instantiations
  • An actual object in the O-O model is instantiated
    from a single class
  • Thus every object is the instance of some class,
    and each class can have zero or more object
    instances
  • Hence, classes are static, object instances are
    dynamic

22
A Class Example - Grand Prix Drivers
Mother
Father
Driving Skill (Inheritance)
Racing Car
Drives (Association)
Contains (Aggregation)
Person
Birth (Instantiation)
Powerful Engine
Pit Stops (Utilisation)
Damen Hill
Pit Crew
Write a Comment
User Comments (0)
About PowerShow.com