OOps stand for object oriented programming.Object oriented programming is a way of solving complex problems by breaking them into smaller problems using objects. Before Object Oriented Programming (commonly referred as OOP), programs were written in procedural language, they were nothing but a long list of instructions. On the other hand, the OOP is all about creating objects that can interact with each other, this makes it easier to develop programs in OOP as we can understand the relationship between them.
What is procedural-oriented programming?
Procedural Oriented Programming is a programming language that follows a step-by-step approach to break down a task into a collection of variables and routines (or subroutines) through a sequence of instructions.
In Object-oriented programming, we write programs using classes and objects utilizing features of OOPs such as Object, class, abstraction, encapsulation, inheritance, and polymorphism.Now we will each and every features.
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 Class?
Collection of objects is called class. It is a logical entity.
What is Inheritance?
When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
What is polymorphism?
When one task is performed in different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle, etc.
In C++, we use Function overloading and Function overriding to achieve polymorphism.
What is Abstraction ?
Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don’t know the internal processing.
In C++, we use abstract class and interface to achieve abstraction.
What is Encapsulation?
Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines.
Advantages of OOP
- We can build the programs from standard working modules that communicate with one another, rather than having to start writing the code from scratch which leads to saving of development time and higher productivity,
- OOP language allows breaking the program into bit-sized problems that can be solved easily (one object at a time).
- The new technology promises greater programmer productivity, a better quality of software, and lesser maintenance cost.
- OOP systems can be easily upgraded from small to large systems.
- It is possible that multiple instances of objects co-exist without any interference,
- It is very easy to partition the work in a project based on objects.
- It is possible to map the objects in the problem domain to those in the program.
- The principle of data hiding helps the programmer to build secure programs which cannot be invaded by the code in other parts of the program.
- By using inheritance, we can eliminate redundant code and extend the use of existing classes.
- Message passing techniques are used for communication between objects which makes the interface descriptions with external systems much simpler.
- The data-centered design approach enables us to capture more details of the model in an implementable form.
Disadvantages of oop
- oop takes longer to learn than traditional programming
- with oop classes tend to be overly generalized
- sometimes the relations among classes become artificial.
- the oop programs can be tricky at times.
- the oop requires proper planning and proper designing for coding.