2. Introduction to Object Orientation Topics
• Overview
• Basic Principles of Object Orientation
• Basic Concepts of Object Orientation
• Strengths of Object Orientation
4/9/2024 2
3. Overview
• What are object-oriented (OO) methods?
– OO methods provide a set of techniques for
analyzing, decomposing, and modularizing software
system architectures
– In general, OO methods are characterized by
structuring the system architecture on the basis of its
objects (and classes of objects) rather than the
actions it performs
• What are the benefits of OO?
– OO enhances key software quality factors of a system
and its constituent components
OO Basics 3
4. OOA, OOD, and OOP
• Object-oriented methods may be applied to
different phases in the software lifecycle
– e.g., analysis, design, implementation, etc.
• Object-oriented analysis (OOA) is a process of
discovery
– models and understands the requirements
of the system
• Object-oriented design (OOD) is a process of
invention and adaptation
– creates the abstractions and mechanisms
necessary to meet the system's behavioral
requirements determined during analysis
OO Basics 4
5. Basic Definitions OOD, and OOP
• Object-Oriented Design (OOD)
– A method for decomposing software architectures based
on the objects every system or subsystem manipulates
– Rather than "the" function it is meant to ensure
• Object-Oriented Programming (OOP)
– construction of software systems using object oriented
concepts as inheritance, polymorphism, encapsulation,
dynamic binding.
• Distinguish between OOD and OOP
– OOD is relatively independent of the programming
language used.
– OOP is primarily concerned with programming language
and software implementation issues
OO Basics 5
6. Object-Oriented Approach
• Model objects that are part of the problem
• Have objects exhibit their normal behavior
• Add objects that do not have problem-space
analogs
• Have the objects work together to create a
solution
Design patterns help you identify less-obvious
abstractions and the objects that can capture them.
- GOF
OO Basics 6
7. Five Basic Characteristics of OO
"Pure" object-orientation by Alan Kay (Smalltalk):
• Everything is an object.
• A program is a bunch of objects telling each
other what to do by sending messages.
• Each object has its own memory made up of
other objects.
• Every object has a type.
• All objects of a particular type can receive the
same message.
OO Basics 7
9. What Is Abstraction?
• The essential characteristics of an entity that
distinguishes it from all other kinds of entities.
• Defines a boundary relative to the perspective of the
viewer.
• Is not a concrete manifestation, denotes the ideal
essence of something.
4/9/2024 9
Salesperson: Not
saying Which
salesperson – just a
salesperson in general!!!
Customer
Product
Manages Complexity
10. What Is Encapsulation?
• Hides implementation from clients.
– Clients depend on interface.
4/9/2024 10
Improves Resiliency
11. Encapsulation
• "Encapsulation is a mechanism used to hide the
data, internal structure, and implementation details
of an object. All interaction with the object is through
a public interface of operations." (Craig Larman)
• A boundary exists around each object;
– the boundary encapsulates the object’s characteristics
(data elements) and behaviors (functionality).
• The reason for hiding features is to:
(1) keep users from touching parts of the object
they shouldn’t touch;
(2) allows creator of the object to change the object’s internal
working without affecting the users of the object.
4/9/2024 11
12. What Is Polymorphism?
• The ability to hide many different
implementations behind a single interface.
4/9/2024 12
Manufacturer A
Manufacturer B
Manufacturer C
OO Principle:
Encapsulation Remote Control
13. Polymorphism
• Occurs with inheritance.
• Different subclasses may have different
implementations of the identical operations
• Allows you to treat an object as the base class,
rather than as a specific inherited type.
• Programmer doesn’t have to keep track of the
specific subclasses, the system selects the correct
operation based on the object type.
• Accomplished at run time using dynamic binding.
– lets you substitute objects that have identical interfaces for
each other at run-time.
4/9/2024 13
14. What is Hierarchy?
4/9/2024 14
Decreasing
abstraction
Increasing
abstraction
Asset
RealEstate
Savings
BankAccount
Checking Stock
Security
Bond
Elements at the same level of the hierarchy
should be at the same level of abstraction
Levels of abstraction
16. What is an Object?
• Informally, an object represents an entity, either
physical, conceptual, or software
– Physical entity
– Conceptual entity
– Software entity
4/9/2024 16
Truck
Chemical Process
Linked List
17. A More Formal Definition
• An object is a concept, abstraction, or thing with
sharp boundaries and meaning for an
application
• An object is something that has:
– State
– Behavior
– Identity
4/9/2024 17
18. What is a Class?
• A class is a description of a group of objects with
common properties (attributes), behavior
(operations), relationships, and semantics
– An object is an instance of a class
• A class is an abstraction in that it:
– Emphasizes relevant characteristics
– Suppresses other characteristics
4/9/2024 18
OO Principle: Abstraction
19. 4/9/2024 19
Sample Class
a + b = 10
Class
Course
Properties
Name
Location
Days offered
Credit hours
Start time
End time
Behavior
Add a student
Delete a student
Get course roster
Determine if it is full
20. Representing Classes in the UML
• A class is represented using a rectangle with
three compartments:
– The class name
– The structure (attributes)
– The behavior (operations)
4/9/2024 20
Professor
- name
- employeeID : UniqueId
- hireDate
- status
- discipline
- maxLoad
+ submitFinalGrade()
+ acceptCourseOffering()
+ setMaxLoad()
+ takeSabbatical()
+ teachClass()
22. Classes and Objects Relationship
• A class is an abstract definition of an object
– It defines the structure and behavior of each object in
the class
– It serves as a template for creating objects
• Objects are grouped into classes
4/9/2024 22
Objects Class
Professor Smith
Professor Jones
Professor Mellon
Professor
23. What Is an Attribute?
• An attribute is a named property of a class that
describes the range of values that instances of
the property may hold.
– A class may have any number of attributes or no
attributes at all.
4/9/2024 23
Attributes
Student
- name
- address
- studentID
- dateOfBirth
24. What Is an Operation?
• A service that can be requested from an object
to effect behavior. An operation has a signature,
which may restrict the actual parameters that are
possible.
• A class may have any number of operations or
none at all.
4/9/2024 24
Operations
Student
+ get tuition()
+ add schedule()
+ get schedule()
+ delete schedule()
+ has prerequisites()
25. What is an Interface?
• Interfaces formalize polymorphism
• Interfaces support “plug-and-play” architectures
4/9/2024 25
Tube
Pyramid
Cube
Shape
Draw
Move
Scale
Rotate
<<interface>>
Realization relationship (stay tuned for realization relationships)
26. Interface
• How do you get an object to do useful work for
you?
• Objects are known only through their interfaces
• Every object presents an interface to the world.
• Interface determines what you can get an object
to do.
• Represent a "contract" with other objects.
• Communicate with objects by sending messages
to them; an object’s interface is the set of
messages an object will respond to.
4/9/2024 26
27. What is a Package?
• A package is a general purpose mechanism for
organizing elements into groups
• A model element which can contain other model
elements
• Uses
– Organize the model under development
– A unit of configuration managemen
4/9/2024 27
Package Name
28. Relationships
• Association
– Aggregation
• Dependency
• Inheritance
• Realization
4/9/2024 28
ConsoleWindow
Window
open()
close()
move()
display()
handleEvent()
Event
DialogBox Control
association
generalization
29. Relationships: Association
• Models a semantic connection among classes
4/9/2024 29
Professor University
Works for
Class
Association
Association Name
30. Relationships: Association Aggregation
• To model a “whole/part” relationship, use
aggregation.
• Aggregation represents a “has-a” or “is a part-of”
relationship, meaning that an object of the whole
has objects of the part.
[Martin Fowler]
30
4/9/2024
Company Department
*
1
31. Association: Multiplicity and Navigation
• Multiplicity defines how many objects participate
in a relationships
– Specified for each end of the association
• Associations are bi-directional by default, but it is
often desirable to restrict navigation to one
direction
4/9/2024 31
Customer Account
1 0..*
Multiplicity
Navigation
32. Relationships: Dependency
• A relationship between two model elements where a
change in one may cause a change in the other
– E.g. Class A depends on class B: method of A manipulates
objects of B in the parameters, local variables, or return types
4/9/2024 32
Package
ClientPackage SupplierPackage
Client Supplier
Class
Dependency
relationship
36. What Gets Inherited?
• A subclass inherits its parent’s attributes,
operations, and relationships
• A subclass may:
– Add additional attributes, operations, relationships
– Redefine inherited operations (use caution!)
• Common attributes, operations, and/or
relationships are shown at the highest applicable
level in the hierarchy
4/9/2024 36
Inheritance leverages the similarities among classes
37. 4/9/2024 37
Example: What Gets Inherited
Truck
tonnage
GroundVehicle
weight
licenseNumber
Car
owner
register( )
getTax( )
Person
0..*
Trailer
1
Superclass
(parent)
Subclass
generalization
size