Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

DFC3013 :

OBJECT ORIENTED PROGRAMMING


(Topic 1)
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
Basic object technology concept and terminology
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
OOP Concept
What is Object?
Any entity that has state and behavior is
known as an object.
For example: chair, pen, table, keyboard,
bike etc.
It can be physical and logical.
What is Object Oriented Programming (OOP)?
A type of programming in which
programmers define not only the data type
of a data structure, but also the types of
operations (functions) that can be applied to
the data structure.
In this way, the data structure becomes an
object that includes both data and functions.
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
History of OOP
1960s
Objects as a formal concept in
programming were introduced in Simula
67, a programming language designed
for discrete event simulation
created by Ole-Johan Dahl and Kristen
Nygaard of the Norwegian Computing
Center in Oslo

Ole-Johan Kristen Kristen Ole-Johan


Dahl Nygaard Nygaard Dahl
History of OOP
1970s
The Smalltalk language, which was developed at
Xerox PARC (by Alan Kay and others) introduced
the term object-oriented programming to
represent the pervasive use of objects and
messages as the basis for computation.

Alan Kay
History of OOP
1970s 1980s
Object-oriented features have been added to
many existing languages during that time,
including Ada, BASIC, Fortran, Pascal, and others.
Probably the most commercially important recent
object-oriented languages are Visual Basic.NET
(VB.NET), C#, .NET platform and Java.

1990s and above


Object-oriented programming developed as the
dominant programming methodology when
programming languages supporting the
techniques became widely available
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
Advantages of OOP
Code extensibility
It is also extensible, as objects can be extended to
include new attributes and behaviors.
Code reusability
Objects created for Object Oriented Programs can
easily be reused in other programs.
Represent real world
In Object Oriented Programming we are trying to
model either real world entities or processes and
represent them in software.
Data Security
This characteristic of encapsulation (data hiding)
provides greater system security and avoids
unintended data corruption
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
Basic terminologies of OOP
Object
Any entity that has state and behavior.
Object is the term used to explain many things. Example:
student, chair and circle.
An Object consists of data and method
Properties of an object are called data. In the real world,
characteristics of an object can be divided into two
types:
Data that can be seen such as a human with two
hands.
Data that cannot be seen such as a human with a
name.
Method is a set of function that manipulates data, such
as method DetermineStatus() can determine exam result
for object student
Basic terminologies of OOP
Object
Any entity that has state and behavior.
Object is the term used to explain many things. Example:
student, chair and circle.
An Object consists of data and method
Properties of an object are called data. In the real world,
characteristics of an object can be divided into two types:
Data that can be seen such as a human with two
hands.
Data that cannot be seen such as a human with a
name.
Method is a set of function that manipulates data, such as
method DetermineStatus() can determine exam result for
object student

Object : Student
Data : name, address, icno, sid, marks, status
Method : DetermineStatus()
Basic terminologies of OOP
Classes
A class is a blueprint or prototype from which objects are
created. Objects with similar properties and methods are
grouped together to form a Class
A set of objects that have similar attributes and methods.
Attributes and methods of a class can be used by each
object from that class.

class Student class Box


{ String name, address, status; { double width, height, depth; data
int icno, sid; data
double marks; double ComputeVolume()
{ return( width * height * depth ); }
char DetermineStatus() method
{ if marks >= 40 double ComputeArea() method
status = Pass; { return( width * height ); }
else }
status = Fail;
}
} Class

Example 2 : Definition of Class Box


Example 1 : Definition of Class Student
Basic terminologies of OOP
Encapsulation
Encapsulation is a process of tying together all data and
methods that form a class and control the access to data by
hiding its information.
The wrapping up of data and its functions into a single unit is
called Encapsulation.
It enables access to object just by using methods of that
object.
It is one of the security features in OOP.

If the college management wants to


Class Student get the status whether a student
pass or fail, they only have to
Name, Student ID, Address, IC No know the status without knowing how
to determine or calculate the grade.
Calculate_result()
So, this is a way of implementing
Determine_grade() encapsulation where the code in the
program is hidden thus to prevent
Print_result() from being modified.
Basic terminologies of OOP
Data Abstraction
Data abstraction is a process to delete all unnecessary
attributes and remain the necessary attributes to describe
an object
Data Abstraction also represents the needed information in
the program without presenting the details.
Attributes and methods of a class can be used by each
object from that class.
Student Class
Student Object

Attribute
Abstraction
Name, Student ID,
Address, IC No

Behaviors

Calculate_mark (),
Determine_grsde (),
Print_result ()
Basic terminologies of OOP
Inheritance
Create a new class from an existing class together with new
attributes and behaviours.
Inheritance is the process of forming a new class from an
existing class or base class.
The new class will have the same ability as the base class.
Use the concept of code reusability.

Class A Base class to class B

Derived class to class A


Class B
Base class to C, D and E

Class C Class D Class E Derived class to class B


Basic terminologies of OOP
Polymorphism
Polymorphism is a process of giving the same message to
two or more different objects and produce different
behaviours depending on how the objects receive the
message.
Polymorphism allows routines to use variables of different
types at different times.
The word "polymorphism" means "many forms - the ability to
appear in many forms.

Example 1:
Message: Withdraw a money from bank

Action Object
Student1 : Using ATM machine from Bank account.

Student2 : Using ATM Machine from other Bank (MEPS)


Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
Abstraction vs encapsulation
Abstraction Encapsulation
Delete all Control the access to
unnecessary data data by hiding its
and remain the information
necessary data
only
Course Learning Outcome
Chapter 1 : Introduction to OOP
Concept of Object Oriented Programming
OOP concept
History of OOP
Advantages of using OOP
Basic terminologies of OOP
Abstraction vs Encapsulation
Structured programming vs OOP approach
Basic object technology concept and terminology
Abstraction vs encapsulation
Structured Programming Object Oriented Programming

Based on programmer definition Object Oriented Programming


function Technique
1 Split a big program to several The use of encapsulation concept
functions. Each function will combined data and function in
perform the task more specific. one component ( class).

Program code cannot be Allowed code reusability


reused It can be done through
2 Each function assign to do inheritance technique. This
specific task only. We must technique allowed object to
accept the function as it is. To inherits characteristic (function
modify it, the code need to and data) other object.
copy and modify it based on it
requirement
Abstraction vs encapsulation
Structured Programming Object Oriented Programming
Data manipulation function Using encapsulation to react on
Data will be send to specific data
3 function to be manipulate Encapsulation is used to package
where the function is not data with function that will take an
determine first. action over the data. It define
which function will be perform to
each object. Class will control any
operation done to data and
function inside it.
No data control access. Restriction in retrieving data.
Main function will access all Access control exist for each
4 data and function in the data in the class.
program.
Not supported polymorphism Used polymorphism
Each data must be declared Allowed one function to be
5 before do any operation on it. executed with various method.

You might also like