4 ms·
Many of the claimed advantages of "data-oriented design" and especially drawbacks of OOP in this article have nothing to do with data-oriented design or OOP...
by mytailorisrich 5y ago
Many of the claimed advantages of "data-oriented design" and especially drawbacks of OOP in this article have nothing to do with data-oriented design or OOP... They are symptoms of bad design.
For instance, good design, and in fact a key concept of OOP, will get you modularity. Especially "When you write code specifically to transform data, you end up with small functions, with very few dependencies on other parts of the code" is the objective of good OO design!
Likewise for testing, I don't see how OOP is a problem if you've designed your system well and kept objects nicely encapsulated (likewise a badly-designed system will always be problematic).
Cache utilization is neither here nor there. It all boils down to memory allocation and, again, choice of objects.
Do data-oriented design to work out your dataflow, and then apply OO principles. A key issue is always to choose your objects 'wisely' and a data-oriented analysis will help towards that goal.
- ChrisMarshallNY 5y agoThis is one reason that I’m always skeptical of dogma. My only tool is a hammer… But that said, many new techniques (I clearly remember when OOP was the “new paradigm”) can offer radical improvements to the status quo. I use OOP all the time, but I also don’t do data processing engines. Most of what I do is GUI and/or device control/communication. For these types of things, OOP is still very much a mainstay, and probably always will be. I won’t sniff at DDD, but get really tired of being lectured about the way I do things; just because it doesn’t involve “buzzword du jour.” BTW: I remember a guy at a conference, telling me about exactly this problem with OOP, in the late 1980s. That was back when OOP was a relatively new kid on the block, and he was arguing against using it. He was correct, but it did not apply, in my use case. The massive improvement in complexity management and quality, offered by OOP, far outstripped any speed advantages of classic procedural programming (which is what he was arguing for).
- beigeoak 5y agoHow much time do you allocate to HN? I see you almost every day in the comments.
- mytailorisrich 5y ago> This is one reason that I’m always skeptical of dogma Yes, this is because too often people follow buzzwords instead of trying to understand the concepts. The issues OO design aims to solve are still valid and still the issue people want to solve. Encapsulation, single responsibility principle, even the concept of object/class (i.e. interacting with data through a set of specific methods) are good design principles, there is no reason to throw them away. It makes sense to use data-oriented design in applications that are data processing intensive, and this is nothing new, but that is orthogonal with using OO principles. Likewise, immutable data can have benefits. This does not mean the concepts above are no longer valid. It means using them with immutable data.
- taffer 5y agoPersonally, I have come to the conclusion that object-level encapsulation is not a good design principle, but rather an antipattern because it complects data with code [1]. OOP tries to manage global mutable state by partitioning and encapsulating it into objects. However, the only way to prevent two unrelated objects from manipulating the same part of the state is to create a tree, i.e., a strict hierarchy between all objects in the system. This combination of data and code in a strict hierarchy means that all data access patterns are baked into this dependency tree, making later, unforeseen changes to the software extremely difficult without taking shortcuts in the dependency tree or having to refactor the entire application. If, on the other hand, you treat your data as just data, preferably flat and immutable, and keep the code that acts on it separate, then you won't run into this problem. You will be able to change the parts of the code that act on the data structures independently. [1] See Rich Hickey, Simple Made Easy: https://www.youtube.com/watch?v=oytL881p-nQ https://www.youtube.com/watch?v=oytL881p-nQ
- ChrisMarshallNY 5y agoAgreed, but, for me, I am not really a data programmer. I tend to work in state and identity (classic UI and communications). For these, that characteristic is actually an advantage. Nowadays, centralized data processing is the big deal for software engineering (as it was, fifty years ago). I'm just a humble app developer, and I'll license stuff that real data programmers do, if I need it.