OOPs. I never posts these at the regular schedule that I want to. Speaking of OOP (Thanks, I know it's an amazing transition), let's talk about Object Oriented Programming! So in my opinion Object Oriented Programming is just as it sounds, you make a program based around thinking its an object rather actions/logic. For example, think of a car. A car has attributes such as color, engine, number of doors, etc. Just like a class, there could be a car class with the same attributes surrounding that object. Additionally, the car class may or may not be able to offer services such as being able to move a certain speed. Similarly, we can make a method for the car class that allows it to move at that speed.
If you think about it this way, OOP can be applied to how we classify things as well. The 'car' class that we just made can have a parent class and sub-classes as well. We can classify a generic vehicle class as a parent class, and we can also classify a specific brand car as a class, for example a BMWclass. With OOP, programs are revolved around creating an instance of an object, where classes are the instructions of how to make the object, and then there can be instances in other people's code. Hopefully my crappy metaphor made some sense, if not here check out this video, it helped me when I was learning about classes!
CLICK ME!
Furthermore there are many benefits to OOP! One of them is its modularity and re usability. The objects created from classes can easily be reused in other code, and also be modified just as easily to better suit the task through implementation (making a subclass). Because of its modularity, parts of a certain class can be changed without syntax issues or compatibility issues (if modified correctly that is). This allows for older versions of code to be modified easily without repercussions.
However, personally the most important benefit of OOP is its design concept. Complex large programs are naturally very difficult to write, but thanks to OOP, it divides the problem into smaller more manageable problems. Because of this, there should always be an extensive planning process reduce the number of possible flaws. Even with those flaws, because of how code is separated into classes (ie. different objects), flaws are easy to fix and locate.
No comments:
Post a Comment