Original Post
What, do you guys find, is the best way to do it? By way of background: I've been mucking my way through some DirectX tutorials for the last week or so, and, in the interest of learning and simplifying things for later use, I'm writing what I guess you would call a 'wrapper' for it (though I'm not 100% clear on the meaning of the term). It's the biggest project I've worked on so far, and the first one where design choices really mean something. My goal here is to set up a framework in which the inner workings of DX and Windows are abstracted away and their functionality is compartmentalized. Clients interface with DX through the framework; setting up a vertex buffer, for example, looks something like graphics.buffers.addVertexBuffer(). I like the idea of this kind of compartmentalization, but, being self-taught and still pretty new at this, I'm uncertain how to deal with some of the intricacies of such a project. The biggest questions I have deal with how to handle dependency between nominally independent modules. To give an example: I have a Graphics class which (gasp) handles my graphics. It has nodes, like BufferNode, VertexNode, EffectNode, etc. My impulse is to keep these as independent as possible. In reality, my vertex node has to feed information to my buffer node, my effect node has to interface with its child nodes (TransformNode, for example), and my Graphics class occasionally has to grab information from one or more of these to do its thing. These connections are probably necessary, but I know there are bad and less bad ways to handle them. What are some of your strategies for dealing with such interconnections? For example, should each node hold a pointer to each of its dependencies? If so, when should these pointers be given out, and who should be responsible for initializing them? Or should each node access its dependencies by worming through the Graphics class, to which each already holds a pointer? Or maybe access should be granted only by passing nodes around as function parameters. This is just the beginning, and I'm sure that as the project grows, it'll only get more complex. So what are some of your favorite strategies for dealing with dependencies? Does the idea for the framework I've laid out sound reasonable, or am I going about it totally the wrong way? Any input y'all have would be much appreciated. Looking forward to your responses!