For years I resisted object oriented programming. If you’re used to linear programming it can be quite a mental adjustment. But there are some very good reasons that the object-oriented approach has revolutionized programming.
Perhaps the easiest way to understand the “objects” of object oriented programming are as specialized stand-alone programs. There are ways to get data into them, ways to get data out of them, and functions that do things with the data.
The important part of this idea is “stand-alone”. The nice thing about the objects is that nothing that happens inside of them directly affects the outside world. This makes it easy for a programmer to use many objects together, even if some of the objects were programmed by someone else. There’s no worry that you might accidentally use the same name for two different variables, or that your programming might conflict with the other person’s methods.
In addition, since each object has a limited, specialized function, if there’s a programming error, it’s easy to find the source, isolate the problem, and fix it without breaking other parts of your program.
The final value of object oriented programming is that it makes it easier to read programming code (at least assuming you understand the OOP programming conventions and syntax!). This is because your main program now contains only the large overall structure of the program. When you get to an object, assuming it is well-named, you can tell what it does at a glance.
Although objects can be quite complex on the inside, if you do ever have to get inside an object and tinker with it, the fact that you know it is designed for specific limited tasks will help you understand what you are looking at. In addition, the fact that objects can contain other objects means that even the inside of an object can benefit from the same simplifying effect as does the main program.
In summary: programmers, don’t be frightened by OOP. An object is nothing but a self-contained program with input, output and internal transformations.
