|
|
Is there anything wrong with circular references? For example, in my case I have the following relationship:
Unit->Hull->Engine Mounting Point->Engine
However, the reverse if also true:
Engine->Engine Mounting Point->Hull->Unit
Now when I render the engine, I am using a separate class in order to separate the behavior from the view. So in this case the following is being implemented:
Engine Renderer->Engine
However, in order to render the engine I also need to know the position of the Engine Mounting Point and the angle of the Unit. So I have two choices:
First when I create the Engine Renderer, I can use the circular reference outlined above and just let the Engine Renderer know about the Engine; when I create the Engine Renderer.
Second choice would be to let the Engine Renderer know about the Unit, Engine Mounting Point, and the Unit.
Engine Renderer->Engine & Engine Mounting Point & Unit
I think I prefer the second choice because it lowers coupling within the model? Anyone else have an opinion? Welcome base Flipcode…
Sean Doherty, BCS www.FreelanceGames.com
|