0
私は、ビヘイビアを適用する抽象的なサブジェクトの実装に基づいて関数の動的な動作を可能にするデザインパターンを探しています。 ステートとコマンドのデザイナーパターンハイブリッド?
抽象例:interface IPlace
{
}
class Garage implements IPlace
{
}
class Backyard implements IPlace
{
}
class Mover
{
void Move(IPlace source, IPlace destination);
}
使用例:
void NotMain()
{
IPlace garage = new Garage();
IPlace backyard = new Backyard();
Mover mover = new Mover();
mover.move(garage, garage);
mover.move(garage, backyard);
mover.move(backyard, garage);
mover.move(backyard, backyard);
}
期待される結果:私は答えはStrategyパターンかもしれないと思うが、私は不明だ
Mover moved an item inside the garage
Mover moved an item from the garage to the backyard
Mover moved an item from the backyard to the garage because it's raining
Mover moved an item around in the backyard
n 2個の異なる振る舞いがあるので振る舞いをどのように決定すべきか、nは実装の数IPlaceインターフェースおそらくMoveOperationオブジェクトを返すファクトリですか?
私は、この種の問題に対するベストプラクティスの解決に興味があります。