在 PureMVC 中实施流程工作流
我正在寻找有关在基于 PureMVC 的应用程序中实施流程/工作流程管理的建议。
我们的 Flex 应用程序包括许多流程,例如帐户创建、付款处理等。
在我们的团队内部,有一些关于我们应该如何严格遵守 PureMVC 模型的讨论。
在 PureMVC 模型中,进程中的当前状态可以在代理中进行管理似乎是合理的。
命令明确负责处理每个节点所需的操作以及节点转换。
用于管理 UI 的中介者。
然而,我认为这里仍然缺少一个重要的部分:ProcessController。
我们审查过的所有方法似乎都违反了 PureMVC 模型(即使只是轻微违反)或导致代码不可读。
代理将维护进程的状态。因此,这似乎是实现控制器的合适方法。然而,这将大量业务逻辑放入代理中。
中介者空间更有意义,但该空间中的控制器不一定直接与任何特定 UI 元素交互,而是会协调/委托给专用中介者。
另一种模型要求我们将流程转换信息放入命令中。虽然这似乎是这项工作的最佳场所(考虑到命令相对于代理和中介的角色),但这种方法看起来会制作一些看起来特别令人发指的代码,其流程转换逻辑分布在数十个命令中。
那么其他人是如何处理这个问题的呢?
感谢 柯蒂斯
I'm looking for suggestions regarding implementing process flow / work flow management in a PureMVC based application.
Our Flex application includes a number of processes such as account creation, payment processing, etc.
Within our team, there is some discussion of how rigidly we should adhere to the PureMVC model.
Within the PureMVC model, it seems reasonable that the current state in the process could be managed in a Proxy.
Commands are clearly responsible for processing the actions required of each node and for node transitions.
Mediators for managing the UI.
However, I think that there is an important bit still missing here: a ProcessController.
The approaches we've reviewed all seem to either violate the PureMVC model (even just slightly) or make unreadable code.
A proxy would maintain the state of the process. As such, it seems to be an appropriate way to implement the controller. However, this is putting a lot of business logic into the proxy.
The Mediator space makes more sense, but the controller in that space would not necessarily directly interact with any particular UI element but would instead coordinate/delegate to dedicated Mediators.
Yet another model would have us put process transition information into Commands. While this seems to be the best place for that work (given the role of commands relative to proxies and mediators), this approach looks to make some particularly heinous looking code with process transition logic distributed among scores of commands.
So how have others handled this problem?
Thank
Curtis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这正是 PureMVC StateMachine Utility(以及一般的有限状态机)要解决的问题。
在简单的 XML 格式中,您可以定义状态、到其他状态的有效转换以及触发这些转换的操作。
它都是基于通知的,因此您发送 StateMachine.ACTION 通知,导致 StateMachine 执行可能需要的任何进入/退出保护逻辑(例如,如果所有数据有效,则仅允许退出 FORM_ENTRY 状态,或者仅允许进入如果用户具有管理员权限等,则为 FORM_PROCESSING 状态)。如果发生状态更改,则会发送通知,可用于在进入新状态时组织视图或执行逻辑。
这是 StateMachine 概述演示文稿,可以让您有更好的想法
http://puremvc.tv/#P003/
This is exactly the problem that PureMVC StateMachine Utility (and Finite State Machines in general) are meant to solve.
In a simple XML format, you can define states, valid transitions to other states, and the actions that trigger those transitions.
It is all notification-based, so you send StateMachine.ACTION notifications that cause the StateMachine to execute any entering/exiting guard logic that may be necessary (e.g., only allow exiting the FORM_ENTRY state if all the data valid, or only allow entry into the FORM_PROCESSING state if the user has admin rights, etc.). If a state change occurs, notifications are sent that can be used to organize the view or execute logic upon entering the new state.
Here is a StateMachine Overview presentation that will give you a better idea
http://puremvc.tv/#P003/
我认为你的“ProcessController”想法可能是更好的方法。就我个人而言,我不喜欢 PureMVC,也不使用它,因为它没有足够的灵活性或扩展点来帮助解决此类问题。
坦率地说,很难就你的问题提供建议,因为我不知道你到底想实现什么目标。我确实同意这一问题需要由一个对象来处理。如果可以的话,尝试创建一个可以存储流程数据的模型,并让另一个类在整个过程中管理它。不确定这是否有意义,但话又说回来,你的问题也不是很清楚。
作为额外的,我会研究依赖注入。我试图记住 PureMVC 是否做到了这一点(我不认为它做到了),但是对于 DI,这将是一个相当简单的问题。像 Parsley 和 Robotlegs 这样的框架在这方面确实很擅长。
I think your idea of 'ProcessController' is probably the better way of doing it. Personally, I'm not a fan of PureMVC and don't use it because it doesn't allow enough flexibility or extension points to help with such problems.
Frankly, it's hard to advise on your issue because I don't know exactly what you're trying to accomplish. I do agree that the concern needs to be handled by one object. If you can, try to create a model that can store the data for the process and have another class just manage it throughout. Not sure if that makes sense, but then again, your problem isn't very clear either.
As an added extra, I would look into Dependency Injection. I'm trying to remember if PureMVC does it (I don't think it does), but with DI it would of been a fairly simple problem to solve. Frameworks like Parsley and Robotlegs are really good at that.
在 pureMVC 中,状态机实用程序可能是过程控制器的最佳选择 - 顺便说一句,根据实现习惯用法和示例最佳实践文档对于 PureMVC,拥有不管理可见组件的中介者是完全可以的
In pureMVC the State Machine Utility is probably the best choice for a process controller - and btw, according to the Implementation Idioms & best Practices doc. for PureMVC, it's perfectly fine to have mediators that don't manage a visible component