01-Introduction To OOP-Additional Notes
01-Introduction To OOP-Additional Notes
Programming Technique II
(SCSJ1023)
Adapted from Tony Gaddis and Barret Krupnow (2016), Starting out with
C++: From Control Structures through Objects
Object Orientation Principle
Divide-and-conquer
Public Interface
Information Hiding
Generality
Extensibility
Abstraction
Principles of Object Orientation
Divide-and-Conquer Principle
The first step in designing a program is to divide the overall
program into a number of objects that will interact with each other
to solve the problem.
Problem solving: Break problems (programs) into small,
manageable tasks.
Principles of Object Orientation
Encapsulation Principle
The next step in designing a program is to decide for each object,
what attribute it has and what actions it will take.
The goal is that each object is a self-contained module with a clear
responsibility and the attributes and actions necessary to carry out
its role
Problem solving: Each object knows how to solve its task and has
the information it needs.
Principles of Object Orientation
Encapsulation Principle
The next step in designing a program is to decide for each object,
what attribute it has and what actions it will take.
The goal is that each object is a self-contained module with a clear
responsibility and the attributes and actions necessary to carry out
its role
Problem solving: Each object knows how to solve its task and has the
information it needs.
For object to work cooperatively and efficiently, we have to clarify
exactly how they are to interact, or interface, with one another.
Each object should present a clear public interface that determines
how other objects will be used.
Principles of Object Orientation
Generality Principle
To make an object as generally useful as possible, we
design them not for a particular task but rather for a
particular kind of task. This principle underlies the use
of software libraries.
Objects should be designed to be as general as
possible.
Objects are designed to solve a kind of task rather than
a singular task.
Principles of Object Orientation
Extensibility Principle
One of the strength of the object-oriented approach is
the ability to extend an object’s behavior to handle new
tasks.
An object should be designed so that their functionality
can be extended to carry out more specialized tasks.
Principles of Object Orientation
Easier debugging
classes can be tested independently
reused objects have already been tested
Self-test: Introduction to Object
Oriented Programming