开发者

Separating View from Model in webapps

I often see web applications where a program is basically some javascript objects wrapping DOM objects. These JS objects perform all model, controller, and view functionality.

This seems ok to me with older style web applications where there really wasn't much model or controller functionality, but in newer more interactive applications, where entire programs are written on top of say Canvas or SVG... there seems like there should be more separation of these开发者_运维百科 components.

Am I right in this or is there a reason why people lump everything together into big JS objects?


Sproutcore is an html 5 javascript application framework that is very strongly mvc. There is a learning curve, but once you get it you get very good separation of concerns between models, views, controllers. Coupled with SC's binding magic, you write very little glue code; i.e. when you load your models from the store the views update automagically. The only work you do is to create the bindings from views -> controllers -> models. It really is very elegant.

I agree with you, as web applications get more and more complicated, MVC is only a good thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜