0% found this document useful (0 votes)
10 views18 pages

4 ConceptObjectOriented Part2

The document outlines key concepts of Object-Oriented Development with Java, focusing on principles such as abstraction, encapsulation, modularity, hierarchy, polymorphism, and generalization. It explains how these principles contribute to the design and structure of classes and objects in programming. The document also provides examples to illustrate each concept, emphasizing their importance in creating manageable and efficient software systems.

Uploaded by

Mark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views18 pages

4 ConceptObjectOriented Part2

The document outlines key concepts of Object-Oriented Development with Java, focusing on principles such as abstraction, encapsulation, modularity, hierarchy, polymorphism, and generalization. It explains how these principles contribute to the design and structure of classes and objects in programming. The document also provides examples to illustrate each concept, emphasizing their importance in creating manageable and efficient software systems.

Uploaded by

Mark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Object Oriented Development

with Java
(CT038-3-2)

Concept of Object Orientation – Part 2


Object Oriented Modeling

Prepared by: Lee Kim Keong First Prepared on: June 13 Last Modified on: April 19
Quality checked by: null
Copyright 2019 Asia Pacific University of Innovation and Technology
Learning outcome

• At the end of this lesson, you will be able


to
– Describe abstraction, encapsulation,
modularity, and hierarchy
– Describe the physical structure of a class
– Describe the relationship between a class and
an object
– Define polymorphism and generalization

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


Basic Principles of Object
Orientation

Object Orientation

Encapsulation
Abstraction

Modularity

Hierarchy
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
What Is Abstraction?

• The essential characteristics of an entity


that distinguishes it from all other kinds of
entities.
• Used to hide certain details and only show
the essential features of the objects
• Defines a boundary relative to the
perspective of the viewer.
• Is not a concrete manifestation, denotes
the ideal essence of something.

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


Example: Abstraction

Student Professor

Course Offering (9:00 a.m.,


Monday-Wednesday-Friday)
Course (e.g. Algebra)

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


What Is Encapsulation?

• A mechanism of wrapping the


data(variables) and code acting on the
data(methods) together as a single unit
• Clients depend on interface.

Improves Resiliency
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
Encapsulation Illustrated

• Professor Clark needs to be able to teach


four classes in the next Professor
semester.Clark

Ac
ce
pt

()
Co

s
ur

de
se

ra
O f fe

G
al
rin

in
g(
)

i tF
Name: J Clark
bm Employee ID: 567138
Su
HireDate: 07/25/1991
Status: Tenured
Se

SetMaxLoad(4) Discipline: Finance


tM

MaxLoad:4
ax
Lo
ad
()

TakeSabbatical()

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


What Is Modularity?

• Breaks up something complex into


manageable pieces.
• Helps people understand complex
systems.

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


Example: Modularity

• For example, break complex systems into


smaller modules. Billing
System

Course
Catalog
System

Course Registration
System Student
Management
System

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


What Is Hierarchy?
Increasing
Asset
abstraction

BankAccount Security RealEstate

Decreasing Savings Checking Stock Bond


abstraction
Elements at the same level of the hierarchy
should be at the same level of abstraction.
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
What Is Polymorphism?

• Polymorphism is the ability of an object to


take on many forms.

Manufacturer B
Manufacturer A Manufacturer C

OO Principle:
Encapsulation

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


Example: Polymorphism

financialInstrument.getCurrentValue()

ge ge ge
tC tC tC
ur ur ur
re re re
nt nt nt
Va Va Va
lu lu lu
e( e( e(
) ) )

Stock Bond Mutual Fund

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


What Is Generalization?

• A relationship among classes where one


class shares the structure and/or behavior
of one or more classes.
• Defines a hierarchy of abstractions in
which a subclass inherits from one or
more superclasses.
– Single inheritance.
– Multiple inheritance.
• Is an “is a kind of” relationship.
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
Example: Single Inheritance

• One class inherits from another.


Ancestor
Account
- balance
Superclass - name
- number
(parent)
+ withdraw()
+ createStatement()

Generalization
Relationship

Subclasses Savings Checking


(children)
Descendents
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
Example: Multiple Inheritance

• A class can inherit from several other


classes.
FlyingThing Animal

Multiple Inheritance

Airplane Helicopter Bird Wolf Horse

Use multiple inheritance only when needed and


always with caution!
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
What Is 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.
CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented
Review

• What are the four principles of object


orientation? Describe each.
• Define polymorphism. Provide an example of
polymorphism.
• What is generalization?

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented


Q&A

CT038-3-2 Object Oriented Development with Java Concepts of Object Oriented

You might also like