Nothing Special   »   [go: up one dir, main page]

The Concept of Object Orientation

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 41

Chapter Two

The Concept of Object


Orientation
© 2009 Pearson Education, Inc. Publishing as Prentice Hall
Chapter Topics
 Real-world objects.
 Object identity.
 Object’s attributes and operations.
 Classes and classification.
 Encapsulation and information hiding
 Object interface.
 Aggregate and composite objects.
 inheritance and polymorphism.
 Object-oriented technology.
 Object-oriented modeling and the Unified
Modeling Language (UML).
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 2
Introducing Objects
 To understand object-oriented technology,
methodology and modeling, we must first
understand what objects are.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 3


An Object Is:
 something that is perceived as an entity
and referred to by name;
 something perceptible by one or more of
the senses;
 something intelligible or perceptible by the
mind.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 4


Identity
 The identity of an object is what distinguishes it
from all other objects.
 Unique:
Unique The object’s identity remains solid and
inviolable, regardless of errors or deliberate attempts by
one entity to fake the identity of another entity.

 Unchanging:
Unchanging an object may change superficially or
profoundly, but our perception of its unique identity does
not change.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 5


Attributes
 Attributes are features, properties, qualities
or characteristics that are associated with
an object.

 Attributes are usually paired with values


that qualify or quantify the attribute.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 6


© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 7
Operations
 An operation is what an object does or is
capable of doing.
 If an object is the subject of a sentence with an
active voice, then the verb expresses an
operation:
 Dog barks
 Ball bounces
 Sun shines

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 8


State of an Object
 State is the condition of an object at a
certain stage in its lifetime.
 An object has a set of attributes and these
attributes accept a range of values. The
combination of these attributes and their
associated values constitute the state of an
object.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 9


State of an Object
 The concept of “state” needs three further
clarifications:
 The condition of an object changes
 The same object can be described by
several states simultaneously, and
 An object may have secondary states
that require a primary state, but can
change without any changes in the
primary state.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 10


Class
 Class is a set of objects that share the
same attributes and operations.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 11


Abstraction
 Abstraction is identifying those
characteristics (attributes and operations)
of an entity that distinguish it from other
kinds of entities.
 The process of selection that separates
certain attributes and operations from a
concrete object is called abstraction.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 12


Generalization
 To generalize is to conclude that
characteristics of a particular entity apply
to a broader range of entities.
 Needed to construct a Class

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 13


Instance
 An instance is the concrete manifestation
of a class.

 For example, John Doe is an “instance” of the


class Human.
Human

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 14


Superclass and Subclass
 A superclass results from generalizing a set
of classes.

 A subclass results from specializing a


superclass.

 The relationship among superclasses and


subclasses is called class hierarchy.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 15


Virtual Objects
 Information systems are composed of
virtual objects that embody the same
concepts as real objects.

 All characteristics of real objects apply to


virtual objects but, for a virtual object,
class is both an abstraction and a template.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 16


Real Object vs Virtual Object

- (Objects/Instances
Class Employee of Class Employee)
Employee - Employee 1
(Real World) -id
-Employid - Employee 2
-Name - Employee 3
-Address - …
-… - Employee n

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 17


Two Types of Class
 Business Classes
 “Business” classes are those that have a
counterpart in the real world. The discovery of
this type of classes and their relationships is
the main task of analysis.
 Patient, student, tree, poet, shirt
 Utility Classes
 Utility classes are those that lack a direct
counterpart in the real world and are used to
create objects that manage the responsibilities
of the information system.
 Command buttons, menus, dropdown lists
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 18
Attributes and Operations
of Virtual Objects
 Attributes and operations of virtual objects
are defined, not discovered.

 The range of values that can be assigned


to an attribute is called the attribute’s
domain.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 19


Encapsulation
 Encapsulation is the
packaging of data and
processes within one
single unit.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 20


Information Hiding
 Information hiding conceals and protects
what goes on inside an object from the
outside world.
 When you use an ATM, encapsulation and
information hiding ensure that:
 you are not burdened with the complexity of
how the machine works,
 cannot perform operations that you are not
allowed to, and
 cannot change the way the machine operates.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 21


Interface
 An object’s interface
consists of operations
that are available to
the public.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 22


Aggregation and Composition

 In object-oriented terminology, the


relationship of one object to its component
objects is called aggregation.

 A strong form of aggregation in which the


life of components relies on the life of the
whole is called composition.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 23


Aggregation and Composition

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 24


Abstract and Concrete Classes
 Classes that can be instantiated into actual
(real or virtual) objects are called concrete
classes.

 Classes that cannot be instantiated into


actual (real or virtual) objects are abstract
classes.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 25


© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 26
Inheritance
 Inheritance is the
mechanism by which a
subclass incorporates
the behavior of a
superclass.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 27


© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 28
Polymorphism

 Polymorphism is the ability of objects belonging to


different classes to perform the same operation
differently.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 29


Object-Oriented Technology
 Object-oriented technology is a response to
the ever-increasing demand for complex
information systems. It has become
possible by the immense leaps achieved by
the information technology.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 30


Object-Oriented Languages
 Simula
 Smalltalk
 C++
 PowerBuilder
 visual Basic
 Java
 .Net

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 31


Object-Oriented Modeling
 Object-oriented analysis and design is
using an object-oriented approach to
building conceptual and logical models of
the system.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 32


The Unified Modeling Language (UML)
 UML is a modeling language for object-
oriented system analysis, design and
deployment. UML is not a product, nor is it
a process or a methodology.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 33


The Unified Modeling Language
 The Unified Modeling Language is a
language, that provides the “primitives” (or
the basic elements) for building object-
oriented conceptual (analysis) and concrete
(design) models.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 34


UML Supports Multiple Views of Same
System
 Owner’s View
 what the owner (or business) wants, or the
conceptual view of the system.
 Architect’s View
 how the architect conceives the solution, or
the logical view of the system.
 Builder’s View
 the blueprints for building the product, or the
physical view of the system.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 35


UML Embodies Four Properties
① Visualization
② Specification
③ Construction
④ Documentation

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 36


Visualization: UML Diagrams
 UML provides a set of graphical elements that are
combined to form diagrams. Each diagram is a
visual presentation or view of the system and
satisfies one or more broad but overlapping types
of modeling:
 Behavioral
 modeling represents the interaction of the system
with the outside world.
 Structural
 modeling represents the components of the system
and their interrelationships.
 Dynamic
 modeling represents how the components of the
system interact with the outside world and with each
other to satisfy the behavioral requirements of the
system.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 37
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 38
Specification, Construction, and
Documentation
 Specification
 UML provides precise and complete models for
the three major activities of system
development: analysis (behavioral model),
design (conceptual model), and implementation
(interactive model).
 Construction
 UML models are compatible with object-
oriented languages.
 Documentation
 UML modeling tracks major development
activities throughout the system lifecycle.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 39


Next: Methodology
 In the next chapter, we shall discuss
methodology. We shall also argue that an
iterative and object-oriented approach,
combined with modeling, offers the best
hope for software development projects.

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 40


All rights reserved. No part of this publication may be reproduced, stored in a
retrieval system, or transmitted, in any form or by any means, electronic,
mechanical, photocopying, recording, or otherwise, without the prior written
permission of the publisher. Printed in the United States of America.

Copyright © 2009 Pearson Education, Inc.  


Publishing as Prentice Hall

© 2009 Pearson Education, Inc. Publishing as Prentice Hall 2- 41

You might also like