Вы находитесь на странице: 1из 30

OBJECT-ORIENTED

PROGRAMMING
Programming Languages

 A programming language is a
computer language programmers
use to develop software
programs, scripts, or other sets
of instructions for computers
to execute.
Structure of Programming Languages

Data Structure – data types, data


elements, operations, built in libraries
Program Structure – textual units that
make up the program, statements, and
subprograms
Control Structure – expressions,
conditional expressions, looping
statements
Levels of Programming Language

Machine Language
Assembly Language
High level Language
Machine Language
 The fundamental language of the computer’s
processor, also called Low Level Language.
 All programs are converted into machine language
before they can be executed.
 Consists of combination of 0’s and 1’s that
represent high and low electrical voltage.

5
Assembly Language

 A low level language that is similar to


machine language.

 Uses symbolic operation code to represent


the machine operation code.

6
High Level Language

 Computer (programming) languages that are


easier to learn.
 Uses English like statements.
 Examples are C ++, C#, Visual Basic, Pascal,
Fortran and …....

7
Object-Oriented Programming

It refers to a type of
computer programming
(software design) in
which programmers define
the data type of a data
structure, and also the types
of operations (functions) that
can be applied to the data
structure.
Basic OOP Concepts

j e ct
ob
c l as s
a t i o n
p s u l
en c a
c t i o n
t r a
abs n c e
e r i t a
inh p h i sm
m o r
pol y
Object-Oriented Programming

 An object is anything that can be


represented by data in a computer’s
memory and manipulated by a
computer program.
Object-Oriented Programming
An object is anything that can be represented by data.
What is an Object?
 An object is an instance of a class
 Objects have the following qualities:
 Identity: Objects are distinguishable from
one another
 Behavior: Objects can perform tasks
 State: Objects store information that can
vary over time
Class
Class
12
Object
Object
Object
Object
123

245
245
What is an Object?

An object can be something


in the physical world or
even just an abstract idea.

A bank transaction is an
example of an object that
is not physical.
What is an Object?

The data that represent the object are


organized into a set of properties.

The values stored in an object’s properties at


any one time form the state
of an object.
Example of an Object

If the class is the blueprint then it will remain a drawing


unless somebody builds a house out of it. Likewise, the class
will have no output unless we create an object out of it. The
object will be the outcome of the blueprint.

Constructio
n
The Two Parts of an Object

Object = Data + Methods


What is a Class?

 A class is a group of
objects with the
same properties
and the same
methods (behavior).
What is a Class?

We can think of an object


as a collection of
properties and the
methods that are used to
manipulate those
properties.

Properties

Methods
Superclass, Subclass, and Inheritance

Musical Instruments Class Hierarchy


What Is Inheritance?
 Inheritance specifies a “is-a-kind-of” relationship
 Multiple classes share the same attributes and
operations, allowing efficient code reuse
 Examples: Base Class
 A customer “is a kind of” person Person
 An employee “is a kind of” person

Derived Classes Customer Employee


Two Variants of Inheritance

 Single Inheritance exists when a class has


only one immediate (parent) superclass
above it.

Figure 12. Single Inheritance


Two Variants of Inheritance

 Multiple Inheritance allow a class to be


derived from several parent superclasses
located above that class.

Figure 13. Multiple Inheritance


What is Polymorphism?

From the name itself, it means many and forms.


Polymorphism is the method of recycling a block of code and
changing it to another form.
What is Polymorphism?

There are several ways to perform polymorphism.

 Polymorphism with class methods


 Polymorphism with Inheritance
 Polymorphism with a Function and Objects
Polymorphism

Employee Class Hierarchy Polymorphism


What is Abstraction?
It is the concealing how something works. Imagine
buying a new Plash Speed 5, inside the package is a manual
how to operate the Plash Speed 5. It explains how you can
use the Plash Speed but it doesn’t explain how the Plash
Speed works internally. Likewise, abstraction is the hiding of
the actual implementation of codes. This can be done by
using abstract classes or abstract methods.

Note: This is not a paid advertisement


Abstraction and Encapsulation
 A class is a blueprint that describes an object and defines
attributes and operations for the object
 Classes use abstraction to make available only the elements
essential to defining the object
 Classes use encapsulation to enforce an abstraction

What the user sees: What is encapsulated:

//verify language
//authenticate PIN
//validate account bal
//adjust account bal
What is Encapsulation?

If abstraction is hiding the internal implementation of


codes, encapsulation protects the integrity of data inside the
program. It restricts the modification of the values of the
variables / field / member by restricting the access on the
variables.
Characteristics of an OO Data Model

 An Object-Oriented Data Model Must:


 Support the representation of complex objects.

 Be extensible; i.e., it must be capable of defining new data


types as well as the operations to be performed on them.
 Support encapsulation; i.e., the data representation and
the method’s implementation must be hidden from
external entities.
 Exhibit inheritance; an object must be able to inherit the
properties (data and methods) of other objects.
 Support the notion of object identity (OID).
REFERENCES

 Source:
https://www.webopedia.com/TERM/O/object
_oriented_programming_OOP.html

Вам также может понравиться