Is there a name for this type of design?
So I am writing a game (c#, xna), and was just wondering if there is a name for what I am doing.
This isn't necessarily specific to Game Programming, or my game. But programming and encapsulation in general.
Essentially I have two game objects, one (Chute) is dependent on the data of another (the list of Blueprints in BlueprintManager). I don't want to expose the BlueprintManagers list of Blueprints to the outside world. However Chute needs to know them to operate.
So instead of exposing the list of Blueprints, I created a method in BlueprintManager which accepts a Chute, and in that method "gives" it's Blueprints to the Chute.
Now I am wondering if this is an effective way to maintain the encapsulation of my data. Also I am wondering if there is a name for this type of method/design. Any best practices for this?
This code is in BlueprintManager which has the list of Blueprints which Chute needs.
public void GiveChuteBlueprints(Chute chute)
{
chute.AcceptBlueprint开发者_高级运维s(this._acitveBlueprints);
}
This looks like the Visitor pattern to me.
精彩评论