Ok to instantiate an object in the View?

自闭症网瘾萝莉.ら 提交于 2019-12-02 10:17:07

Firstly, it is okay to instantiate an object in the view. Nothing will probably blow up in your face. However, then you miss the whole advantage of splitting your architecture into tiers.

It is better to instantiate the object in the controller. Some of the reasons include - better reuse, much simpler testing, better design because of the decoupling.

See the articles on presentation patterns here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!