There have been a bunch of blog entries, with slightly different points of view, discussing the decline of object oriented programming. I think most of them miss the mark communicating the arc of history when it comes to programming paradigms.
At a fundamental level, as programming languages have evolved they have improved on two different dimensions:
At a fundamental level, as programming languages have evolved they have improved on two different dimensions:
- Abstraction - allowing the developer to develop components at higher and higher levels of abstractions.
- Encapsulation - allowing the developer to hide more and more details from the users of their components.
Let me give you a specific example from my C++ days. At the time, I was using the Oracle Call Interface (OCI) - a C language API to connect to Oracle databases. Using Perl::DBI, we used code generation to automatically generate C++ classes based on the schema metadata. The class layout looked something like this:
This object oriented design had a few design features that I consider object oriented:
- The complicated interface between the C library for OCI calls and the C++ code was hidden in the relationship between the connection class and the abstract table class.
- All of the table classes had a common interface for dealing with columns, date formats and all of the other details you want to be consistent with a database interface.
- The OCI library allowed for fetching into arrays of memory. While this performed much better, keeping track of what memory was in use and which was not was an easy thing to get wrong and we were able to hide that from the users of the generated classes as well. Those users don't know it, but the multiple instances representing rows were associated to a single storage instance and copies of the data were made for them if and when copies of the entity table class were created.
Newer languages, such as GoLang, allow you to define the common behavior between classes through interfaces that can be defined without any preconceived decisions made by whichever class was developed first.
You could look at it like the following progression:
- C function to pointers - like void (*fun_ptr)()
- Arrays of pointers to functions associated to class definitions - the original C++ vtable
- Arrays of pointers to functions associated later binding - GoLang
The critical programming concept here is that the combination of an abstraction with encapsulation is an object. And those are not going anywhere.
Comments
Post a Comment