何时使用 Windows Workflow Foundation?

发布于 2024-07-05 21:32:25 字数 1449 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

咋地 2024-07-12 21:32:25

就我个人而言,我不喜欢WF。 对我来说,它的用处并不像其他新的 MS 技术(例如 WPF 或 WCF)那么明显。

我认为 WF 将来会在业务应用程序中大量使用,但我没有计划使用它,因为它似乎不是适合我的项目的合适工具。

Personally, I'm not sold on WF. It's usefulness wasn't as obvious to me as other new MS technologies, like WPF or WCF.

I think WF will be used heavily in business applications in the future, but I have no plans to use it because it doesn't seem like the right tool for the job for my projects.

望她远 2024-07-12 21:32:25

一般来说,如果您不需要持久性和跟踪功能(我认为这是主要功能),则不应使用 Workflow Foundation。

以下是我从我的经验中总结出的 Workflow Foundation 的优点和缺点:

优点

  • 持久性:如果您将有许多长时间运行的流程(想想几天、几周、几个月),那么 Workflows 非常适合这。 空闲的工作流实例会持久保存到数据库中,因此不会占用内存。
  • 跟踪:WF 提供了跟踪工作流程中执行的每个活动的机制
  • *视觉设计器:我将其标记为 *,因为我认为这实际上仅对营销目的有用。 作为一名开发人员,我更喜欢编写代码,而不是通过视觉方式将事物组合在一起。 当你有一个非开发人员制作工作流程时,你常常会陷入一片混乱。

缺点

  • 编程模型:编程功能确实有限。 想想 C# 中所有出色的功能,然后忘记它们。 C# 中简单的一两行语句就变成了相当大的活​​动块。 这对于输入验证来说尤其是一个痛苦。 话虽如此,如果您真的很小心地只保留工作流中的高级逻辑,而将其他所有内容保留在 C# 中,那么这可能不是问题。
  • 性能:工作流占用大量内存。 如果您要在服务器上部署大量工作流程,请确保有大量内存。 另请注意,工作流程比普通 C# 代码慢得多。
  • 学习曲线陡峭,难以调试:如上所述。 您将花费大量时间来弄清楚如何让事情发挥作用,并找出做某事的最佳方式。
  • 工作流版本不兼容:如果您部署具有持久性的工作流,并且需要对工作流进行更新,则旧的工作流实例不再兼容。 据说这已在 .NET 4.5 中修复。
  • 您必须使用 VB 表达式(.NET 4.5 允许使用 C# 表达式)。
  • 不灵活:如果您需要 Workflow Foundation 未提供的某些特殊或特定功能,请做好承受很多痛苦的准备。 在某些情况下,这甚至是不可能的。 在你尝试之前谁知道呢? 这里存在很大的风险。
  • 没有接口的 WCF XAML 服务:通常使用 WCF 服务,您可以针对接口进行开发。 使用 WCF XAML 服务,您无法确保 WCF XAML 服务已实现接口中的所有内容。 您甚至不需要定义接口。 (据我所知...)

In general, if you do not need the persistence and tracking features (which in my opinion are the main features), you shouldn't use Workflow Foundation.

Here are the advantages and disadvantages of Workflow Foundation I gathered from my experience:

Advantages

  • Persistence: If you're going to have many long running processes (think days, weeks, months), then Workflows are great for this. Idle workflow instances are persisted to the database so it doesn't use up memory.
  • Tracking: WF provides the mechanism to track each activity executed in a workflow
  • *Visual Designer: I put this as a *, because I think this is really only useful for marketing purposes. As a developer, I prefer to write code rather than snapping things together visually. And when you have a non-developer making workflows, you often end up with a huge confusing mess.

Disadvantages

  • Programming Model: You're really limited in programming features. Think about all the great features you have in C#, then forget about them. Simple one or two line statements in C# becomes a fairly large block activities. This is particularly a pain for input validation. Having said that, if you're really careful to keep only high-level logic in workflows, and everything else in C#, then it might not be a problem.
  • Performance: Workflows use up a large amount of memory. If you're deploying a lot of workflows on a server, make sure you have tons of memory. Also be aware that workflows are much slower than normal C# code.
  • Steep learning curve, hard to debug: As mentioned above. You're going to spend a lot of time figuring out how to get things to work, and figuring out the best way to do something.
  • Workflow Version Incompatibility: If you deploy a workflow with persistence, and you need to make updates to the workflow, the old workflow instances are no longer compatible. Supposedly this is fixed in .NET 4.5.
  • You have to use VB expressions (.NET 4.5 allows for C# expressions).
  • Not flexible: If you need some special or specific functionality not provided by Workflow Foundation, prepare for a lot of pain. In some cases, it might not even be possible. Who knows until you try? There's a lot of risk here.
  • WCF XAML services without interfaces: Normally with WCF services, you develop against an interface. With WCF XAML Services, you cannot ensure a WCF XAML Service has implemented everything in an interface. You don't even need to define an interface. (as far as I know...)
冷︶言冷语的世界 2024-07-12 21:32:25

仅当满足以下任一条件时,您才可能需要 WF:

  1. 您有一个长时间运行的流程。
  2. 您有一个经常更改的流程。
  3. 您需要该过程的可视化模型。

有关更多详细信息,请参阅 Paul Andrew 的帖子:使用 Windows Workflow Foundation 做什么?

请不要将 WF 与任何类型的可视化编程混淆或联系起来。 这是错误的,可能会导致非常糟糕的架构/设计决策。

You may need WF only if any of the following are true:

  1. You have a long-running process.
  2. You have a process that changes frequently.
  3. You want a visual model of the process.

For more details, see Paul Andrew's post: What to use Windows Workflow Foundation for?

Please do not confuse or relate WF with visual programming of any kind. It is wrong and can lead to very bad architecture/design decisions.

醉殇 2024-07-12 21:32:25

绝不。 您可能会后悔:

  • 陡峭的学习曲线
  • 难以调试
  • 难以维护
  • 无法提供足够的功能、灵活性或生产力增益来证明其使用的合理性
  • 可能并且将会破坏无法恢复的应用程序状态

我唯一能想到使用 它WF 是指如果我想为最终用户托管设计器,甚至可能也不会。

相信我,没有什么比您编写的代码更简单、更强大或更灵活,可以完全满足您的需要。 远离WF。

当然,这只是我的观点,但我认为这是一个非常好的观点。 :)

Never. You will probably regret it:

  • Steep learning curve
  • Difficult to debug
  • Difficult to maintain
  • Doesn't provide enough power, flexibility, or productivity gain to justify its use
  • Can and will corrupt application state that cannot be recovered

The only time I could ever conceive of using WF is if I wanted to host the designer for an end-user and probably not even then.

Trust me, nothing will ever be as straightforward, powerful, or flexible as the code that you write to do exactly what you need it to do. Stay away from WF.

Of course, this is only my opinion, but I think it's a damn good one. :)

ゝ偶尔ゞ 2024-07-12 21:32:25

WF 生成的代码很糟糕。 WF 带来的价值在于系统的视觉表示,尽管我还没有看到任何我不喜欢更简单的手工编码项目的东西(我参与过的 WF 现在有 6-7 个项目) 。

The code generated by WF is nasty. The value that WF brings is in the visual representation of the system, although I have yet to see anything (6-7 projects at work now with WF that i've been involved with) where I would not have preferred a simpler hand coded project.

草莓味的萝莉 2024-07-12 21:32:25

我发现使用工作流基础的主要原因是它在跟踪和持久性方面给您带来了很多开箱即用的效果。 持久化服务的启动和运行非常容易,这带来了多个实例和主机之间的可靠性和负载分配。

另一方面,就像表单应用程序一样,工作流设计器向您推荐的代码模式很糟糕。 但是,您可以通过在工作流中不编写任何代码并将所有工作委托给其他类来避免问题,这些类可以比工作流更优雅地组织和单元测试。 然后你就可以得到设计师炫酷的视觉效果,而无需背后繁琐的意大利面条代码。

The major reason I've found for using workflow foundation is how much it brings you out of the box in terms of tracking and persistence. It's very easy to get the persistence service up and running, which brings reliability and load distribution between multiple instances and hosts.

On the other hand, just like forms apps, the code patterns that the workflow designer pushes you towards are bad. But you can avoid problems by writing no code in the workflow and delegating all work to other classes, which can be organized and unit tested more gracefully than the workflow. Then you get the cool visual aspect of the designer without the cruft of spaghetti code behind.

樱娆 2024-07-12 21:32:25

我目前工作的公司建立了 Windows Workflow Foundation (WF),他们选择使用它的原因是因为规则会经常更改,这将迫使他们重新编译各种 dll 等,因此他们的解决方案是将规则放置在数据库中并从那里调用它们。 这样他们就可以改变规则,而不必重新编译和重新分发 dll 等。

The company I am currently working for set up a Windows Workflow Foundation (WF) and the reasons they chose to use it was because the rules would frequently be changing and that would force them to do a recompile of the various dll's etc and so their solution was to place the rules in the DB and call them from there. This way they could change the rules and not have to recompile and redistribute the dlls etc.

清风挽心 2024-07-12 21:32:25

Windows 工作流像它的表亲 BizTalk 一样吸引着非编码 IT 经理、BA 等,但在实践中,单元测试、调试和代码覆盖率只是众多陷阱中的三个。 您可以克服其中一些问题,但您必须投入大量资金才能实现这一点,而使用纯代码您就可以做到这一点。 如果您确实有长期运行的需求,那么您可能需要更复杂的东西。 我听说过关于能够在不重新编译 dll 的情况下将新的 xaml 文件投入生产的争论,但说实话,工作流消耗的时间可以更好地用于改进持续集成,使编译部署不再成为问题。

Windows Workflows seduce non-coding IT managers, BAs and the like as does its cousin BizTalk but in practice unit testing, debugging and code coverage are just three of the many pitfalls. You can overcome some of them but you have to invest heavily in achieving that whereas with plain code you just get that. If you genuinely have a long-running requirement then you probably need something more sophisticated. I've heard the argument about being able to drop new xaml files into production without re-compiling dlls but honestly the time that Workflows will consume could be better used to improve your Continuous Integration to the point where compiled deploys aren't a problem.

清欢 2024-07-12 21:32:25

我会在任何需要使用工作流的环境中使用它,但是当将它与 K2 甚至 SharePoint 2007 结合使用时,该平台的强大功能确实非常有用。 当与 BI 专家一起开发业务应用程序时,建议使用该平台,这通常只与简化和改进业务流程相关。

据记录,WF 是与 K2 开发团队联合开发的,新的 K2 Blackpearl 是在 WF 之上构建的,MOSS 2007 和 WSS 3.0 的工作流引擎也是如此。

I would use it in any environment where I need to work with workflow, however when using it in conjuction with K2 or even SharePoint 2007 the power of the platform is truly useful. When developing business applications with BI specialist the use of the platform is recommended and this would normally only be relevant to streamline and improve business processes.

For the record WF was developed in conjunction with K2's development team and the new K2 Blackpearl is built on top of WF, so is MOSS 2007 and WSS 3.0's workflow engines.

遮了一弯 2024-07-12 21:32:25

当你不想手动编写所有这些代码来维护可视化界面、跟踪和持久化时,投票给 WF 是一个明智的选择。

When you don't want to manually write all those codes to maintain the visual interface, tracking and persistence, it's a wise choice to vote for WF.

送你一个梦 2024-07-12 21:32:25

我已经使用 Windows 工作流几个月来开发自定义活动和重新托管的设计器,非开发人员可以使用它来构建工作流。 WF 非常强大,但它的好坏取决于开发人员构建的自定义活动。 归根结底,开发人员必须查看非开发人员构建的工作流程来进行测试和调试,但从他们可以创建草稿工作流程的角度来看,这太棒了。

此外,如果您有长时间运行的进程,当您需要动态更新进程时,WF 是一个很好的技术堆栈,无需重新安装/下载或执行任何操作,只需将新的 XAML 文件添加到目录中,您的体系结构应该是设置版本控制以废弃旧版本并使用新版本。

I have been using Windows workflow for months now to develop custom activities and a re-hosted designer that non-developers can use to build workflows. WF is very powerful but it is only as good as the custom activities that are built by developers. When it comes down to it, a developer would have to look over workflows built by non-developers to test and debug but from the point they can create draft workflows- that is fantastic.

Furthermore, in cases where you have long running processes WF is a good tech stack to use when you need to update processes dynamically - without having to reinstall/download or do anything, just add the new XAML files to a directory and your architecture should be set up with versioning to scrap the old one and use the new one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文