领域模型实现中是否应该考虑UI项目类型?
嗯,问题就在标题中:)。只是关于这个问题的一些想法...
我正在考虑我的应用程序的域模型。我发现状态模式很适合我,因为我有改变其状态的业务对象,并且状态有严格的顺序,而且还有许多逻辑依赖于状态的操作。
不过我知道我的用户界面将是网络应用程序。由于 Web 应用程序是无状态的(在其一般实现中),因此状态只会更改一次,并且我不会获得状态模式的所有好处。在这种网络场景中,我什至不需要更改 someAction 中的 StateObject 。
那么也许只创建状态顺序规则而不使用状态模式会更好?
Hmm, the question is in title :). Just some thoughts about the problem...
I'm thinking of domain models of my application. I've found that State pattern suits me well as I have Business object that changed its state and states have strict order, also there are number of operations which logic is depends on State.
However I know that my UI will be web application. As web applications is stateless (in its general implementation) then State will be changed only one time and I won't have all benefits of state pattern. I even don't need to change StateObject in someAction in such web scenario.
So maybe it will be better just to create rules of states order and don't use State pattern?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的领域层不应该知道您的 UI 层。域对象应该被创建为与 UI 无关。这并不是说域对象不能以与 UI 配合使用的方式进行设置;而是说域对象可以与 UI 一起使用。这取决于项目,也是我现在正在处理的事情。
Your domain layer shouldn't be aware of your UI layer. Domain objects should be created to be UI-agnostic. That's not to say that a domain object can't be set up in a way to work with UI; it depends on the project, and is something I'm dealing with now.