Object Oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable pieces of code blueprints (usually called classes), which are used to create individual instances of objects. There are many object-oriented programming languages including JavaScript, C++, Java, and Python.
A class is an abstract blueprint used to create more specific, concrete objects. Classes often represent broad categories, like Car or Dog that share attributes. These classes define what attributes an instance of this type will have, like color, but not the value of those attributes for a specific object.
Classes can also contain functions, available only to objects of that type. These functions are defined within the class and perform some action helpful to that specific type of object.
For example, our Car class may have a function repaint that changes the color attribute of our car. This function is only helpful to objects of type Car, so we declare it within the Car class thus making it a method.
Class templates are used as a blueprint to create individual objects. These represent specific examples of the abstract class, like myCar or goldenRetriever. Each object can have unique values to the properties defined in the class.
For example, say we created a class, Car, to contain all the properties a car must have, color, brand, and model. We then create an instance of a Car type object, myCar to represent my specific car.
We could then set the value of the properties defined in the class to describe my car, without affecting other objects or the class template.
We can then reuse this class to represent any number of cars.
Re-usability It means reusing some facilities rather than building it again and again. This is done with the use of a class. We can use it ‘n’ number of times as per our need.
Code Maintenance This feature is more of a necessity for any programming languages, it helps users from doing re-work in many ways. It is always easy and time-saving to maintain and modify the existing codes with incorporating new changes into it.
Security With the use of data hiding and abstraction mechanism, we are filtering out limited data to exposure which means we are maintaining security and providing necessary data to view.
Design Benefits If you are practicing on OOPs the design benefit a user will get is in terms of designing and fixing things easily and eliminating the risks (if any). Here the Object Oriented Programs forces the designers to have a longer and extensive design phase, which results in better designs and fewer flaws. After a time when the program has reached some critical limits, it is easier to program all the non-OOP’s one separately.
Better productivity with the above-mentioned facts of using the application definitely enhances its users overall productivity. This leads to more work done, finish a better program, having more inbuilt features and easier to read, write and maintain. An OOP programmer cans stitch new software objects to make completely new programs. A good number of libraries with useful functions in abundance make it possible.
Easy troubleshooting lets witness some common issues or problems any developers face in their work.
Problems solving Decomposing a complex problem into smaller chunks or discrete components is a good practice. OOP is specialized in this behavior, as it breaks down your software code into bite-sized – one object at a time. In doing this the broken components can be reused in solutions to different other problems (both less and more complex) or either they can be replaced by the future modules which relate to the same interface with implementations details.
The following video introduces what OOP is and why you may want to use this paradigm.
Dan Shiffman provides his take on OOP. Don’t worry too much about the code that does not make sense. He is describing Processing (p5’s older brother which is based on the Java programming language).