人们对patterns的热衷似乎并不是一个很健康的标志,比如来自Microsoft®的一个pattern:MVVM(Model-View-ViewModel),它似乎已经被深深的植根到每一个WPF应用中。然而,就是MVVM的发明人John Gossman却向人们发出了警告的声音:
“The overhead inimplementing MVVM is “overkill” for simple UI operations. He also states thatfor larger applications, generalizing the View layer becomes more difficult.Moreover, he illustrates thatdata binding, if not managed well, can result in considerable memory consumptionin an application.”(引自wikipedia)
除此而外,我们还有几点需要注意:
- Code非常宝贵的一个要求就是:simplicity,因为,code实现的business logic的复杂性已经耗尽了我们大部分的脑力。然而应用一个pattern时,一般而言势必会增加code的数量和logic flows。
- 据有关说明:MVVM的最大的好处之一是提高了unit test测试的可行度。但是,这个好处是与unit test的有效性等因素紧密相关的,防止出现这样的情形:MVVM所增加的复杂度超过了unit test可能带来的好处。
- MVVM所要求的data binding机制比较复杂,很可能会有效率等问题影响我们的技术选择。