WPF / Silverlight的程序员:是MVVM矫枉过正? [英] WPF/Silverlight Programmers: Is MVVM Overkill?

查看:120
本文介绍了WPF / Silverlight的程序员:是MVVM矫枉过正?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是有关于MVVM百感交集。看来我需要code这么多的得到最补救工作的事情。我想念事件(指挥是这样的痛苦),结合一切导致调试噩梦,我怀念有一个参考的观点!

I just have mixed feelings about MVVM. It seems I need to code so much to get the most remedial things to work. I miss events (commanding is such a pain), binding everything leads to a debug nightmare, and I miss having a reference to the view!

我只是想知道你的MVVM的感情VS落后方式普通的老code。你喜欢什么更好的和/或做什么,你通常使用或推荐使用?

I was just wondering about your feelings of MVVM vs the plain old code behind way. What do you like better and/or what do you normally use or recommend using?

感谢

推荐答案

我肯定在这其中的少数,但我倾向于同意@Shnitzel。 MVVM,并结合了云手牵手呢,是伟大的想法,但他们当前MS工具,服务很差。语法为所有,但最简单的绑定是很难得到的权利,并取得了很大的困难的事实,WPF和Silverlight默默吞下所有错误。 (是的,一些错误出现在调试窗口,但没有足够的人,没有足够的细节。)您可以使用黑客就像写一个调试值转换器,但事实上,该工具仍是pretty的不成熟。 (再有就是我的标准的投诉,数据绑定不是强类型,这意味着该工具无法捕捉到错误给你。)

I'm definitely in the minority on this one, but I tend to agree with @Shnitzel. MVVM, and the binding that goes hand-in-hand with it, are great ideas, but they're poorly served by the current MS tools. The syntax for all but the simplest bindings is very difficult to get right, and is made much harder by the fact that WPF and Silverlight silently swallow all the errors. (Yes, some of the errors show up in the debug window, but not enough of them, and without enough detail.) You can use hacks like writing a debug value converter, but the fact remains that the toolset is still pretty immature. (And then there's my standard complaint, that data binding isn't strongly typed, which means that the tools CAN'T catch the errors for you.)

我听听大家的时候,他们坚持的可测试性,我为自动化测试的忠实粉丝。但至少我们的工具的当前状态,MVVM的改进可测试性是在一个pretty的大价钱。

I hear everyone when they insist on testability, and I'm a big fan of automated testing. But at least with the current state of our tooling, MVVM's improved testability comes at a pretty big price.

考虑这种情况:你有一个大的应用程序与50多个表单/页,而你刚刚从事模型和视图模型的一个重要的重构。在这个过程中,你改名了一堆类和属性等。现在发现在你的XAML的每一个地方,你需要改变以反映新类和属性名。这么多的可测试性,是吗?不仅将IDE抓不住你的绑定错误,编译器不会赶上他们,而且,最重要的是,应用程序甚至不会在运行时抛出一个错误。你必须让测试人员通过整个应用程序的运行,并确保所有绑定都还在做你希望他们做的事。 Ugggh。丑陋和痛苦的。至少当我在做的事情老式的方法,编译器会告诉我,当我拼错的东西。

Consider this scenario: you've got a large app with 50+ forms/pages, and you've just engaged in a major refactoring of your Model and ViewModel. In the process, you renamed a bunch of classes and properties, etc. Now find every place in your XAML that you need to change to reflect the new class and property names. So much for testability, eh? Not only will the IDE not catch your binding mistakes, the compiler won't catch them, and, best of all, the app won't even throw an error at runtime. You have to get a tester to run through the whole app, and make sure that all your bindings are still doing what you want them to do. Ugggh. Ugly and painful. At least when I was doing things the old-fashioned way, the compiler would tell me when I misspelled something.

让我们回到了我的洞穴,以避免枪暗箭很快我的领导方式...

Going back into my cave to avoid the slings and arrows quickly headed my way...

这篇关于WPF / Silverlight的程序员:是MVVM矫枉过正?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆