客观地说,Cairngorm 相对于 PureMVC 的优缺点是什么?

发布于 2024-07-05 23:00:44 字数 94 浏览 10 评论 0原文

在 Flex 中使用 MVC 框架的原因有很多,但选择正确的框架似乎很棘手。 我对你们所有人从实施其中一个(或另一个)的经验中得出的想法感兴趣。

山姆

There are so many reasons why using an MVC framework in Flex rocks, but picking the right one seems tricky. I am interested in what you all think from your experiences of implementing either of these (or another).

Sam

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

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

发布评论

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

评论(1

诗笺 2024-07-12 23:00:44

这个问题已经被问过,但是既然您专门询问 Cairngorm 和 PureMVC 的好处,这些我的想法是:

  • PureMVC 和 Cairngorm 都使得编写可测试代码变得困难。 这主要是由于他们使用全局变量将应用程序代码紧密地联系在一起,使得很难隔离任何部分进行测试。 Cairngorm 比 PureMVC 更是如此,但两者都非常糟糕。

  • PureMVC 比 Cairngorm 更具侵入性(意味着您的代码严重依赖于框架,例如您必须子类化/实现框架类/接口),但这并不意味着 Cairngorm 不是。

  • Cairngorm 充满了反模式,例如大量使用全局变量,PureMVC 隐藏了自身最糟糕的部分。

    Cairngorm 充满了反模式,例如大量使用全局变量

  • PureMVC 是反 Flex 的,Cairngorm 只是没有使用 Flex 的许多优点。 我的意思是 PureMVC 重新发明了 Flex 已经拥有的许多东西,因为它希望与平台无关,并且由于它的架构,特别是中介器,它使得更难充分利用绑定。 Cairngorm 只是跳过事件冒泡之类的东西,而是选择涉及全局变量的解决方案。

简而言之,Cairngorm 是 Fl​​ex 的 VisualBasic,它可以工作,但会教你很多坏习惯。 PureMVC 并没有那么糟糕,它只是不太适合编写 Flex 应用程序。

我认为你应该看看 Mate,它充分利用了 Flex 的潜力,而且它不是内置的围绕全局变量。 相反,它可以帮助您编写松散耦合、可测试、可重用和可维护的代码,而无需像其他应用程序框架那样对框架产生严重且不必要的依赖。

如果您出于某种原因不喜欢 Mate,请尝试 Swiz,这是一个很大的改进优于 Cairngorm,但仍然对使用全局变量进行中央事件调度有一些奇怪的偏好(考虑到框架的要点之一是避免 Cairngorm 的邪恶全局变量,这完全奇怪)。

The question has already been asked, however since you ask specifically for the benefits of Cairngorm and PureMVC specifically, these are my thoughts:

  • Both PureMVC and Cairngorm make it hard to write testable code. This is mostly down to their use of global variables that tie your application code together tightly, making it hard to isolate any part for testing. This is more true of Cairngorm than PureMVC, but both are pretty bad.

  • PureMVC is more invasive than Cairngorm (meaning that your code is heavily dependent on the framework, e.g. you have to subclass/implement the framework classes/interfaces), but that doesn't mean that Cairngorm isn't.

  • Cairngorm is full of anti-patterns like heavy use of global variables, PureMVC hides the worst parts of itself.

  • PureMVC is anti-Flex, Cairngorm just doesn't use many of the good parts of Flex. By this I mean that PureMVC reinvents many things that Flex already have, because it wants to be platform agnostic, and because of its architecture, specifically the mediators, it makes it harder to use bindings to their full power. Cairngorm just skips over things like event bubbling, and instead opts for solutions involving global variable.

In short, Cairngorm is the VisualBasic of Flex, it works but will teach you a lot of bad habits. PureMVC isn't so bad, it just isn't a very good fit for writing Flex applications.

What I think you should look at is Mate, which uses Flex to it's full potential, and it isn't built around global variables. Instead it helps you write loosely coupled, testable, reusable and maintainable code without the heavy and needless dependencies on the framework that you see in other application frameworks.

If you for some reason don't like Mate, try Swiz, which is a great improvement over Cairngorm, but still has some weird preference for using global variables for central event dispatching (which is completely bizarre considering that one of the points of the framework is to avoid the evil global variables of Cairngorm).

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