[go: up one dir, main page]

0% found this document useful (0 votes)
20 views5 pages

OOP Paradigm

Uploaded by

anee.cse8.bu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

OOP Paradigm

Uploaded by

anee.cse8.bu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

OOP paradigm with examples

Object-Oriented Programming
Object oriented programming is a method to design a program using classes and
objects. It uses to simplify the software development and maintenance by
providing some concepts defined below:

1. Class: Class is a user-defined data type that defines its properties and its
functionality. Class is the only logical representation of information.

2. Object: An object is an instance of a class. Object is used to represent a


place, person or any other things.

3. Attribute: An attribute is basically called data. It’s actually defines the


properties of an object.

4. Method: Methods are a block


code or functions. That are related to and allowed to be accessed by an object.
And change the data inside that object. Methods declared inside the class.
Methods defines behaviors of an object. They are announced within a class
and used to perform specific tasks.
5. Encapsulation: Encapsulation allows for data hiding. Class data members
(variables) are usually identified as private or protected, so that they
cannot be accessed directly from outside the class.

6. Inheritance: A process called inheritance that automatically gives an


object all the data and behaviors of its parent object. In this way, the
data and behaviors defined in other classes can be reused, extended,
or modified.
7. Abstraction: It’s hided unnecessary things loke details and allowed the user
to show only the necessary parts/functionality.

Polymorphism: Polymorphism can represent the same interface


for different underlying forms actually for data types. With the help of
polymorphism, each of these classified data types have different underlying
data.

The advantage and disadvantage of OOP are given below:

Advantage:
• Modularity: OOP helps to break down programs into smaller, more
manageable modules. This makes programs easier to understand,
maintain, and test.
• Abstraction: OOP allows programmers to abstract away the details of
how objects work, so that users can focus on what the objects do, rather
than how they do it. This can make programs easier to use and
understand.
• Extensibility: OOP makes it easy to add new features to programs
without having to change existing code. This is because new features can
be added by creating new classes that are inherited from existing classes.

Dis-advantage:
• Performance: OOP can sometimes lead to slower program execution,
especially if objects are heavily interconnected.
• Memory usage: OOP can sometimes lead to increased memory usage,
especially if objects are large or if they are created and destroyed
frequently.
• Overuse of inheritance: Improper use of inheritance can lead to rigid and
inflexible codebase, making it difficult to modify and extend the system
without causing unexpected side effects.
• Not suitable for all problems: While OOP is beneficial for certain types of
applications, it may not be the best choice for all programming problems.
Some tasks may be better suited to other paradigms like functional
programming or procedural programming.

You might also like