|
|
|
|
|
by yaantc
1601 days ago
|
|
I don't remember seeing a criticism of OOP that is a criticism of encapsulation. Everybody tends to agree that encapsulation is desirable. It seems to me criticisms of OOP are that it rolls too many things into one construct, the class: it's a type, with encapsulation of methods and data structure, plus inheritance, all into one. And it can lead to not so efficient data placement on modern CPU (AoS vs SoA). Languages like Ada and Ocaml have object orientation extensions to the initial languages (Ada 83, and Caml/SML) that can very often be ignored. And still are very good for encapsulation. With them, modules (packages for Ada) and types are separate. It is very natural to group close types together into one module, while exporting opaque abstract types only usable through a module services. Rolling different concepts into the class may give a more intuitive result at first, particularly when simulating real world entities. But it's also a bit limiting compared to keeping those concepts orthogonal. |
|