Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
211 views

Object-Oriented Programming Paradigm

The document discusses the object-oriented programming paradigm. It describes key characteristics like classes, abstraction, encapsulation, inheritance, and polymorphism. It provides an example in Java of creating a class called Addition to calculate the sum of the first ten natural numbers as an illustration of object-oriented concepts. The document also lists popular object-oriented programming languages and reasons for considering learning the object-oriented paradigm like code reuse, flexibility, security, and improved productivity and quality.

Uploaded by

Angana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
211 views

Object-Oriented Programming Paradigm

The document discusses the object-oriented programming paradigm. It describes key characteristics like classes, abstraction, encapsulation, inheritance, and polymorphism. It provides an example in Java of creating a class called Addition to calculate the sum of the first ten natural numbers as an illustration of object-oriented concepts. The document also lists popular object-oriented programming languages and reasons for considering learning the object-oriented paradigm like code reuse, flexibility, security, and improved productivity and quality.

Uploaded by

Angana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Object-oriented programming paradigm

➢ OOP is the most popular programming paradigm because of its unique advantages like
the modularity of the code and the ability to directly associate real-world business
problems in terms of code.

➢ The key characteristics of object-oriented programming include Class, Abstraction,


Encapsulation, Inheritance and Polymorphism.

➢ A class is a template or blueprint from which objects are created.

Objects are instances of classes. Objects have attributes/states and methods/behaviors.


Attributes are data associated with the object while methods are actions/functions that the object
can perform.
Abstraction separates the interface from implementation. Encapsulation is the process of hiding
the internal implementation of an object.
Inheritance enables hierarchical relationships to be represented and refined. Polymorphism
allows objects of different types to receive the same message and respond in different ways.
To illustrate, let's find the sum of first ten natural numbers in the object-oriented paradigm
approach.

Example in Java:

public class Main


{
public static void main(String[] args) {
Addition obj = new Addition();
obj.num = 10;
int answer = obj.addValues();
System.out.println("The sum is = "+answer); //prints-> The sum is 55
}
}
class Addition {
int sum =0;
int num =0;
int addValues(){
for(int i=1; i<=num;i++){
sum += i;
}
return sum;
}
}
➢ We have a class Addition that has two states, sum and num which are initialized to zero.
We also have a method addValues() which returns the sum of num numbers.
➢ In the Main class, we've created an object, obj of Addition class. Then, we've initialized
the num to 10 and we've called addValues() method to get the sum.

Languages that support the object-oriented paradigm:

• Python

• Ruby

• Java

• C++

• Smalltalk

Why should you consider learning the object-oriented programming paradigm?


• Reuse of code through Inheritance.

• Flexibility through Polymorphism.

• High security with the use of data hiding (Encapsulation) and Abstraction mechanisms.

• Improved software development productivity: An object-oriented programmer can stitch


new software objects to make completely new programs (The Saylor Foundation, n.d.).

• Faster development: Reuse enables faster development (The Saylor Foundation, n.d.).

• Lower cost of development: The reuse of software also lowers the cost of development.
Typically, more effort is put into the object-oriented analysis and design (OOAD), which
lowers the overall cost of development (The Saylor Foundation, n.d.).

• Higher-quality software: Faster development of software and lower cost of development


allows more time and resources to be used in the verification of the software. Object-
oriented programming tends to result in higher-quality software (The Saylor Foundation,
n.d.).

You might also like