How to apply Data Oriented Design with Object Oriented Programming?

Pombal
  • How to apply Data Oriented Design with Object Oriented Programming? Pombal

    I've read lots of articles about Data Oriented Design (DOD) and I understand it but I can't design an Object Oriented Programming (OOP) system with DOD in mind, I think my OOP education is blocking me. How should I think to mix the two? The objective is to have a nice OOP interface while using DOD behind the scenes.

    I saw this too but didn't help much: https://stackoverflow.com/questions/3872354/how-to-apply-dop-and-keep-a-nice-user-interface

  • I would say that Noel Llopis's blog is probably the best instruction for a combination of object-oriented programming and data-oriented design. He is one of the originators of the DOD term, is a strong C++ programmer, and has written a good deal about his style and how he takes advantage of C++'s OO features.

    I guess if I were to call out the key elements of combining them, according to Noel:

    • Use POD and non-member, non-friend functions as much as possible. Non-member, non-friend functions improve encapsulation and are a key part of data-orientation because they keep the data, data.
    • Avoid storing "temporary" state on your objects. Temporary state clogs up your data. If you need to cache something (e.g. for performance) then that belongs in a new class, with non-member non-friend functions linking the two types, not a is-a nor a has-a relationship.
    • Avoid objects that can be in state A or state B. Prefer switching between two objects, one of which is A, and one of which is B.
    • Avoid polymorphism, avoid virtual functions, avoid templates, avoid anything that makes your data have the syntactic appearance of sameness rather than actual sameness.

    The other big name in DOD propaganda right now is Mike Acton of Insomniac, but reading what he's written I'd say he's not really pro-OO (or anti-OO, as long as it's still data-oriented).

Tags
c++ architecture
Related questions and answers
  • I'm creating a component-based game object system. Some tips: GameObject is simply a list of Components. There are GameSubsystems. For example, rendering, physics etc. Each GameSubsystem contains... a decision which Components to register (and how to organize them). For example, GameSubsystemRender can register Renderable Components. pro. Components know nothing about how they are used. Low coupling. A. We can add new GameSubsystem. For example, let's add GameSubsystemTitles that registers all ComponentTitle and guarantees that every title is unique and provides interface to quering objects

  • branches). The trunk of the tree is the root node. It's orientation is aligned to the y axis. In the next iteration of the tree (e.g. the first branches), I might create a branch that is oriented say by +10 degrees in the X axis and a similar amount in the Z axis, relative to the trunk. I know that I should keep a rotation matrix at each branch, so that it can be applied to child branches, along...( 10.0f, 0.0f, 0.0f, 1.0f ); // z rotation Are my maths and approach correct, or am I completely wrong? Finally, I'm using the glm library with OpenGL / C++ for this. Is the order of x rotation

  • the following: Vertices Indices Normals UVs Material Information Animation information (no clue, how to import it) Collision mesh Game Properties defined within 3D authoring tool (object intelligence, aggressivity, etc..) ..another assets.. Can I kindly ask for a hint, how to construct my custom file format. How to organize data within my files, please? Does anoybody have a good adivce... of wasting it on incorrect approaches. I use Softimage as my 3D authoring tool. Target platform is OpenGL ES 2.0 running on mobile devices (iOS, Android). Programming language: C++.

  • Possible Duplicate: Are there existing FOSS component-based frameworks? What open source game engines with component-based design of game objects do you know? And which best of them? I mean best not in Graphics or Physics, but best in context of Behaviour, Messaging, etc. This question is the result of inspiration by another question Thank you!!!

  • server object and the server then receives and sends messages; quite simple. The tricky concepts for me are: What's a good way to run many tables at the same time? What's a good way to keep the lobby... / design ideas for a game with a lobby and many tables? Is there a usual way this is done that I'm overlooking? Any conceptual ideas or even c/c++ code examples would be very helpful. Thanks ...I'm working on learning network programming. I'm working on a simple card game. The basic idea is: Players enter the lobby Players see tables Players sit at an empty seat Once they sit, they do

  • can't think of a decent scheme to use, or the right data-structures required to quickly manage them. Could someone who has implemented a system like this give an overview of how their's worked... in advance of first use. Here is a bit a sketch of the classes I am using: typedef unsigned int ResourceId; // Resource is an abstract data type. class Resource { Resource(); virtual ~Resource(); virtual bool load() = 0; virtual bool unload() = 0; virtual size_t getSize() = 0; // Used in determining how much memory is // being used. bool

  • to worry about this since it isn't an issue there. Moving to C++, this has become a fairly major problem and made me think I may have designed things incorrectly. I can't really imagine how to decouple... question about it is, is this a worthwhile approach at all? If it's a bad design I want to know now before I invest too much more time making all the screens I'm going to need. How do you build up...I've been working on a 2d RPG for awhile now, and I've come to realize I've made some bad design decisions. Theres a few things in particular that are causing me problems, so I was wondering what

  • holds spacial information and a draw method that combines this data with that of the mesh to draw that object with the proper transforms. The mesh is simply responsible for holding pointers to the appropriate buffers. I was under the impression (wrongly I think) that because I actually only have one object of each type that I'm drawing multiple times, that this WAS instancing. I know this isn't...This question directly follows on from this one: How can I implement a renderer that can draw many kinds of primitives? I have a small amount of drawing code structured in the following way

  • program this effectively and efficiently? I am thinking to build this with C and Lua. C++ is also an option. I would store the game state and display the graphics using C. The part that I don't know how to handle is the interaction between C and Lua. Not programming-wise, but design-wise. The interaction between the world and the scripted actors. Should C provide the Lua actors with information, and then have the Lua actors call C functions that change their direction, move a step forward, etc? Will this work in real-time? I realize that this question is broad, but I think it's not unreasonable

Data information