Title: What is Object Orientation
1What is Object Orientation?
2Thoughts
- Like modern physicists, Buddhists see all
objects as processes in a universe, and deny the
existence of any material substance. - Fritjof Capra, physicist and philosopher
- What makes you, and what are your boundaries?
- Douglas Hofstadter, author of Godel, Escher, Bach
3Object Orientation
- The world is not static, but a dynamic process
- Objects that comprise the world are also dynamic
and in constant flux - Models of the world should take this into account
- OO models look at systems as dynamic, not static
4Advantages of OO
- Models are stable
- As entities change, the model adapts
- Construction of systems is iterative
- Stresses reuse of components
- Supported by weak coupling
- Eases development and quality management
5Five Basic Concepts
- Objects
- Messages
- Classes
- Inheritance
- Polymorphism
6Concept 1 Objects
- Definition an atomic entity formed by the union
of state and behavior - A bird sings
- A window shuts
- A cup runneth over
- Objects are typically nouns, behavior is a verb
7Objects
- The fundamental characteristics of an object are
- OBJECT State Identity Behavior
8Object State
- Groups values of the attributes of an object at a
given moment in time - State changes over time
- Attributes may be constant or variable
- CAR
- Silver- 1300 lbs- 6 gallons gas- V8 engine
- CAR
- Silver- 1292 lbs- 2 gallons gas- V8 engine
t1
t2
9Object Identity
- A characteristic that distinguishes objects from
other similar objects - Must be something to differentiate objects, even
if all attributes are identical - natural identifier
- Social security number
- Others?
10Object Behavior
- Groups the abilities (actions and reactions) of
an object - Behavioral components known as operations
- Object operations triggered by messages received
from other objects
11Object Behavior
Object B
message
Object A
Triggers either operation 1 or 2 depending on
message
Operation 2
Operation 1
12Object Communication
- OO systems are collaboration of objects
- Objects work together to implement the
functionality of desired system - Type of communication is, therefore, important
- Categories of behavior (based on direction of
message - Client
- Server
- Agent
13Clients
- Objects that instigate an interaction
- Known as active objects
- Responsible for handing control over to another
object
Agent
Client
Server
14Servers
Agent
Client
- Never instigate an interaction
- Known as passive objects
- Wait for another object to require their service
- Messaging object hands over control and then
retakes it after service is complete
Server
15Agents
Server 1
Agent
Server 2
Client
- Combination of client and server characteristics
- Can interact with any other object
- Interactions can be result of trigger or on their
own (like people) - Act as filters for other objects
Server 3
16Concept 2 Messages
- Definition the unit of inter-object
communication - Dynamically link objects together
- Represented as
Message A
Object B
Object A
Or, if data is involved
Message A
Data B
Object B
Object A
Data A
17Categories of Messages
- Constructors
- Create objects
- Destructors
- Destroy objects
- Selectors
- Return the state of an object
- Modifiers
- Change the state of an object
- Iterators
- Visit the state of an object
18Message Synchronization
- Specifies the nature of the communication between
objects and the rules for passing messages - Message Broadcast Categories
- Simple
- Synchronous
- Rendezvous
- Timed
- Asynchronous
19Broadcast Categories
- Simple
- Only one object active at a time
- Sent from active to passive object
- Synchronous
- Operation triggered only when target accepts
message - Sender waits until acceptance
Object B
Object A
x
Object B
Object A
20Broadcast Categories
Object B
Object A
- Rendezvous
- Inverse of Synchronous
- Message sent if and only if recipient is in
waiting for message mode - Timed
- Sender blocked/waits for limited time for
recipient to respond
call
Carrie
Christine
3 rings
21Broadcast Categories
- Asynchronous
- Sender is not blocked
- Sender does not wait for acknowledgement from
recipient
Letter via US postal service
Carrie
Christine
22Representing the Object Interaction
3Z
Chan Roeun
1X
Joe
2Y
Mike
This is known as a Collaboration Diagram
23What if there are many object interactions?
8M8
Chan Roeun
3M3 5M5
1M1 4M4 10M10
9M9 7M7
Mike
2M2
6M6
Joe
Collaboration Diagram is too cluttered and
confusing
24Sequence Diagram
Chan Roeun
Joe
Mike
M1
M2
M3
M4
M5
M6
M7
M8
M9
M10
25Concept 3 Classes
- Definition of the word class
- Oxford a number of individuals having a
character or feature in common - Webster a number of persons or things regarded
as forming a group by reason of common
attributes, characteristics, qualities or traits
26Classes in everyday life
- Based on similar values for a particular, or
group of attributes - All purple dinosaurs all green apples all
Jesuits - Based on the range of an attribute
- Everyone who is between 18-21 years of age
- Based on similar behavior
- Everyone who sleeps in class everyone in the
ECIS program
27Difficult to verbalize the rule
- Children may have their own, incomprehensible
grouping rule - Adults may have their own incomprehensible
grouping rule - Designers inability to understand users grouping
rule may be result of not understanding business
28All about Classes
- Based on the notion of abstraction
- Starts with identification of all common
characteristics of a set of elements - All objects belong to a class
- Objects represent an instance of a class
- Software objects are built from a class through
instantiation
29Representation of a Class
CLASS NAME
Attributes
Operations ( )
30Representation of a Class
MOTORCYCLE
Color Maximum Speed Engine
Start ( ) Brake ( )
31Describing a Class
- Description of a Class
- Specification
- Definition domain
- Properties of the instances
- Implementation
- How are the specifications implemented
- Details of the operations
- Data needed to allow proper functioning
- Do we really need to know everything about
implementation?
32Encapsulation
- The secret strength of OO methods
- Encapsulation is the hiding of implementation
details - Consider learning to email or learning to drive
as examples - Some things to be treated as a black box
33Advantages of encapsulation
- Stability
- Once the class has been studied and finalized, no
need to change them in later use - Portability
- Possible to reuse the class for different
projects - Minor changes to classes make them more and more
reusable - The published interface should stay the same as
far as possible
34Levels of encapsulation
- By default, attribute values are encapsulated
within an object - Values cannot be manipulated from the outside
Only operations can be triggered - Levels (visibility)
- Private ()
- Protected ()
- Public (-)
35Relationships Between Classes
- Associations
- Objects are linked
- Classes are associated
- Represented as
(a link)
SU University
Joe Student
University
Student
(an association)
36Multiplicity
- Sometimes called the cardinalityof a
relationship - The number of instances of each class that are or
can be involved in a given association
1
University
Student
37Other Examples
Driver
Bus
Customer
Product
Student
Course
1
Advisor
Student
38Roles and multiplicity
1
University
Student
0..1
University
Teacher
May be replaced by..
teacher
employer
0..1
University
Person
1
student
39Next Class
- - Class Hierarchies, Inheritance, and
Polymorphism - -Introduction to OOAD