3 ms·
I had never considered a "data-centric" approach to be anti OOP but from the article: > I am not an OOP convert. I've spent most of my professional life workin
by abetusk 7y ago
I had never considered a "data-centric" approach to be anti OOP but from the article:
> I am not an OOP convert. I've spent most of my professional life working with classes and objects, but the more time I spend, the less I understand why you'd want to combine code and data so rigidly. I want to handle data as data and write the code that best fits a particular situation.
I've come around to the idea much more that data should be the privileged structure and code should be considered transformations of the data. In some sense, code should be light and interchangeable and let the data is the first class citizen.
Are OOP and "data-centric" approaches at odds with each other? Does OOP only have validity when the data is relatively "small" and can be abstracted away easily?
- inimino 7y ago> Are OOP and "data-centric" approaches at odds with each other? Yes, because OOP Objects are data plus code (methods). If you don't have methods, but just pass data around, you don't have OOP. If you do have methods, you meet the "expression problem". If you have static types and well typed code you get pure data at runtime, and if you include unions and product or sum types at runtime, you end up with algebraic datatypes, and if you have RTTI and polymorphism and inheritance then you get classical OOP. If you have just data living in memory at runtime, and just transformations of the data (functions) sitting in your code, then you get FP.