Some decades ago a new programming concept became popular: object-oriented programming. The basic unit of program design would become the class
, and classes could contain methods and fields, and inherit from other classes. Runtime types could determine what methods were called.
All was great, and programs became perfect, with no further bugs ever being introduced. Back in reality, though, OOP introduced a lot of complexity, and it was hard for even experienced developers to grasp. And after learning about OOP and writing about it, I think of it mainly as a program organization strategy.
Here are some of my realizations about OOP:
if
-statements and switches on a field—it seems "more advanced" to call a derived or virtual
method, but in reality, it is just another conditional branch.if
-statements, but they are just more complex to use, and the end result is the same.In conclusion, object-oriented programming is nothing special when it comes to the runtime execution of programs. But it makes it possible to organize programs in a more complex (and possibly harder-to-understand) way. These organizational constructs can be beneficial on larger programs, but are rarely worthwhile on smaller ones.