• Content count

  • Joined

  • Last visited

Community Reputation

108 Neutral

About CramerFish

  • Rank
  1. Pointers to an instance's owner

    Thanks. I did think it smelled a bit fishy. I believe I have some thinking to do...
  2. I have a question about the following design [CODE] class Unit { Manager *my_manager; ... }; class Manager { vector<Unit> unit_list; ... }; [/CODE] In the interest of encapsulation the Unit handles it's own actions (e.g. movement), the pointer to the manager is then required so that the unit can interact with other units (e.g. colliding). It feels like it's a hack, I've added in the pointer in the absence of a better design strategy. Is this an intelligent way to structure my code, or[i] should I be looking for a different design pattern[/i]? I'm from a Maths/Science background and so while I have done quite a bit of programming (FEM, graph theory, simulations) I haven't formally learned application programming. If there is a good book on how to design/structure a program that is more than just datain->process->dataout I would love to hear your recommendations.