You are on page 1of 2

UNIT 01 – INTRODUCTION TO PROGRAMMING

LESSON # 2
TITLE: OBJECT-ORIENTED PROGRAMMING

Terminologies
OOP – Object-Oriented Programming
OOP – it is a programming standard that uses object to design computer programs.
Object – defined as an instance of a class where attributes and methods are placed under a single
name.
Class – defined as the model or template that can be instantiated to create an object.

Discussion

Object-Oriented Programming
OOP simulates real-world interaction. Real-world contains objects that interact with each other (i.e.
phones, computers, people, etc.) Each of these objects has their own attributes (characteristics) and
operations (function or purpose). These two elements of an object form a cohesive package.

With OOP, a problem will be broken down into a number of units and these units are called objects.
The data elements in the object are called attributes and the procedure or function is called method.
Each object is capable of receiving messages, processing data, and sending message to other
object.

OOP has the following advantages over traditional programming approaches:

- OOP provides a clear modular structure for programs which makes it good for defining abstract
data types where implementation details are hidden and the unit has a clearly defined
interface.
- OOP is easy to maintain and modify existing code as new objects can be created based on
existing objects.
- OOP provides a good skeleton for code libraries where software components can be easily
adapted and modified by the programmer.

Object vs. Classes

To clearly understand the concepts of class and object, examine the example given below.
A vehicle can be described in terms of the following set of attributes and behaviors:

Table 1.1 Table 1.2


CLASS OBJECT
VEHICLE CARS
ATTRBUTES BEHAVIORS ATTRBUTES BEHAVIORS
MODEL DRIVING INNOVA DRIVING
BRAND NAME BRAKING TOYOTA BRAKING
NO. OF TIRES OPENING A DOOR 4 OPENING A DOOR
COLOR LOCKING A DOOR GRAY LOCKING A DOOR
Figure 1.1 the diagram illustrates the template for creating a box. It can be used as a pattern to draw
the shape and parts of the box; it is not yet a box.

12”
3”

3” 3” 12”

3”

Fundamental Concepts of OOP


Every program created using the OOP paradigm may contain or implement the following concepts:

1. Encapsulation – a programming mechanism that binds together the code and the data that it
manipulates. It keeps both data safe from outside interference and misuse.
2. Inheritance – a programming concept that describes the object capability to acquire the
properties of another object.
3. Polymorphism – from the Greek word, meaning “many forms”, it is the ability of objects of
different types to respond to methods of the same name, each one according to the right type-
specific behavior.

You might also like