12 hours ago, Bouke285 said:
Won't you have an issue with member variables filling the cache even when you don't need access to them using this approach? Thanks!
Well, that's what I meant by using using DOD to come up with better layouts for your OOP objects.
e.g. If you've got an OOP object where 50% of the member variables are used in data-transformation A, and the other 50% are only used in data-transformation B, then maybe you should split it into two different classes. Note that in that situation, you were probably violating OO's SRP rule in the first place, and by following DOD you're actually getting closer to pure OO theory
Lots of introductory OO classes start with some problem like "Say we've got students and teachers, we can make three classes: Student, Teacher and Person, and Student/Teacher will inherit from Person"... well that's bullshit. It does show you what inheritance is, but it's a complete violation of OO theory. You can't go designing your object layouts/hierarchy until you know what the algorithms are / what the problem you're trying to solve is. Without knowing what the algorithms are, it's impossible to know if inheritance is valid here or not.
Likewise, DOD wants you to very closely inspect your algorithms and the flow of data between them, and then design data layouts that cause the least friction. It's actually good practice for OOP programmers to work this way, instead of trying to design self-contained objects first, without thinking about the big picture algorithms or data flow at all.