OOP Paradigms
OOP Paradigms
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.
6. Inheritance: Inheritance is a process that an object gets all the data and
behaviors of its parent object automatically. In such a way, you can be able
to reuse, extend or modify the data and behaviors that are defined in other
classes.
7. Abstraction: It’s hided unnecessary things loke details and allowed the user
to show only the necessary parts/functionality.
Advantage:
• Reusability: It is easy to reuse code by creating classes that can be used
in multiple programs. This can save time and effort, and it can also help to
ensure that code is consistent across different programs.
• 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.