Java观察者和策略的结合?
Java Observer and strategy combination?
我结合使用了 MVC 模式和观察者模式,其中我的视图是观察者,而我的模型是具有状态的主题。
我 subject/model 中的状态更改可以使用策略模式吗,因为我需要实现几个行为?
是的。您可以实施设计模式的组合来解决您的问题。我想强调以下有关设计模式的要点
- Design patterns are solutions for recurring common problems. They are guidelines to solve a particular problem.
- You can create your own design pattern for your problem. Solving your problem is important than fitting your solution into one of existing design patterns.
- Sometimes design patterns will limit our thinking process into available design patterns,which is not good. You should not be constrained about existing patterns
- Design patterns are facilitators but they are not obligatory
我结合使用了 MVC 模式和观察者模式,其中我的视图是观察者,而我的模型是具有状态的主题。
我 subject/model 中的状态更改可以使用策略模式吗,因为我需要实现几个行为?
是的。您可以实施设计模式的组合来解决您的问题。我想强调以下有关设计模式的要点
- Design patterns are solutions for recurring common problems. They are guidelines to solve a particular problem.
- You can create your own design pattern for your problem. Solving your problem is important than fitting your solution into one of existing design patterns.
- Sometimes design patterns will limit our thinking process into available design patterns,which is not good. You should not be constrained about existing patterns
- Design patterns are facilitators but they are not obligatory