An Introduction to Object Orientation - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

An Introduction to Object Orientation

Description:

In the O-O model, all objects have completely unique names. Example - a watch ... Methods or Demons. Aion DS supports both knowledge bases in the form of rules ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 37
Provided by: simonk8
Category:

less

Transcript and Presenter's Notes

Title: An Introduction to Object Orientation


1
An Introduction to Object Orientation
  • Introduction to Objects
  • The Object-Oriented Approach
  • An introduction to OO analysis, design and
    programming
  • OO vs Frames

2
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 DictionaryA tangible and/or
    visible thing, something that may be apprehended
    intellectually, something towards which thought
    or action is directedBooch

3
quite, but What are Objects?
  • Examples (of which there are many)PeopleMotor
    CarsPersonal Computersbut also Bank Accounts
    and addresses

4
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
    objectAn object can manipulate (change, copy,
    delete) its data

5
Objects Display Behaviour
  • Behaviour is how an object acts and reacts, i.e.
    an objects internal functions
  • Objects are responsible for instructing their own
    functions to operate and for requesting other
    objects to instruct their own functions

6
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

7
Example - a watch
  • Identity - My watch
  • Sate (data) time
  • Behavior
  • Displays current time
  • Set time
  • Stop watch
  • Start watch

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 are never operated uponServers - Only
    ever operated uponAgents - Both operate on and
    are operated upon

10
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

11
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
    e.g.
  • Mammals a class of animals which possess common
    attributes and behaviour (eg. Cows, Monkeys,
    Humans etc) such as hair, suckle young,
    warm-blooded, sexual, smelly etc.

12
Class Interfaces and Implementation
  • Interfaces allow classes to provide a view of
    their internal structure and behaviour to the
    outside world. Usually this is restricted to hide
    none relevant details, e.g. a watch.
  • Implementation of a class is its internal view,
    ie. what states it possess and which behaviours
    it exhibits.

13
Interface Visibility
  • Public Accessible to all clients
  • Protected accessible to itself, subclasses
    and its friends
  • Private accessible only to itself and its
    friends

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

Airplane
Container
Cockpit
Wings
Container/Component
Seats
Engines
Container/Component
15
Class Relationships
  • Inheritance
  • Aggregation
  • Instantiation
  • and also
  • Associations
  • Utilisation

16
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

17
Class Inheritance
Living Entity
Food source
Animal
Plant
Animal inherits directly from Living entity
Mammal
Plant inherits directly from both Living entity
and Food source
Mammal inherits directly from Animal, therefore
also inheriting indirectly from Living entity
18
Class Aggregations
  • Similar to the aggregation exhibited by objects
  • Whole/Part relationship (Container/Component)

19
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

20
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
21
The OO Approach
  • Adopting the Object Paradigm

22
Categories of Analysis and Design
  • Structured Analysis and Design (eg.
    SSADM)Data-Oriented Analysis and Design (eg.
    JSP)Object-Oriented Analysis and Design (see
    later)

23
The Object Model
  • A conceptual framework, a specific way of
    thinkingThree stages in using O-O to model the
    world-OOA (Object-Oriented Analysis)OOD
    (Object-Oriented Design)OOP (Object-Oriented
    Programming)

24
Object-Oriented Analysis
  • Examines user requirements
  • Produces a model of the problem
  • Focus on classes rather than actual object
    instances
  • Initial stage prior to design
  • Analysis model feeds into design process

25
Object-Oriented Design
  • Provides solutions to the problem modelled during
    analysis
  • Follows on from the analysis process and feeds
    into the implementation stage
  • Uses notations to express the logical and
    physical models of the system
  • Concentrates on depicting both static and dynamic
    models

26
Object-Oriented Programming
  • Implements the design models as actual computer
    code
  • Utilises some or all of the principles employed
    by object-orientation
  • O-O languages include C, Eiffel, Smalltalk,
    Object Pascal, Simula

27
Object Model Elements
  • Abstraction
  • Encapsulation
  • Modularity
  • Hierarchy

28
Abstraction
  • Denotes the essential characteristics of an
    object
  • Crisply defined conceptual boundaries
  • Relative to the perspective of the viewer
  • Abstract classes and objects may not actually
    exist

29
Encapsulation
  • Aka Information hiding
  • Abstraction and Encapsulation are complementary
  • Compartmentalises the state and behaviour of
    classes and objects that need to be hidden from
    other classes and objects

30
Modularity
  • Partitioning into individual components to help
    reduce complexity
  • Achieved by the use of objects and classes
  • We require high cohesion (objects and classes)
    and loose coupling (relationships and message
    passing)

31
Hierarchy
  • The ranking or ordering of abstractions
  • Inheritance is hierarchical
  • Subclasses inherit from their superclasses
    (generalisation/specialisation relationship)
  • Other relationships can be hierarchical, eg.
    aggregation

32
Digging out Objects, Classes and Attributes
  • Look for Nouns, these provide classes, attributes
    and object instances (proper nouns)The cat sat
    on the mat. Cat and Mat are classesA cat called
    Tiddles sat on a mat called Martin. Tiddles is an
    instance of class Cat, Martin is an instance of
    class MatA cat with 10 whiskers sat on a mat of
    length 2m. Whiskers is an attribute of class Cat
    and has value 10, Length is an attribute of class
    Mat and has value 2m

33
Digging out Relationships and Behaviours
  • Look for Verbs, these provide insight into the
    relationships between classes/objects and the
    behaviours of classes/objectsThe cat sat on the
    mat. Class Cat has an association relationship
    with class Mat by sitting on it.The cat, which
    is made up from a cat body, cat head, 4 cat limbs
    and a cat tail, sat on the mat. Class cat has a
    11 aggregation relationship with classes Cat
    Body, Cat Head, Cat Tail and a 14 aggregation
    relationship with class Cat Limbs

34
Digging out Relationships and Behaviours
  • The purring cat sat on the flying mat. To purr
    is a behaviour of the class Cat To fly is a
    behaviour of the class matThe tiger, which is a
    member of the cat family, sat on the rug, which
    is a kind of mat . Class Tiger inherits from the
    Cat class Class Rug inherits from the Mat class

35
OO vs Frames
  • OO and frames both support
  • Abstraction
  • Hierarchy
  • Inheritance,
  • Methods or Demons
  • Aion DS supports both knowledge bases in the form
    of rules and OO programming

36
Summary
  • In this lecture we have looked at
  • Introduction to Objects
  • The Object-Oriented Approach
  • An introduction to OO analysis, design and
    programming
  • OO vs Frames
Write a Comment
User Comments (0)
About PowerShow.com