Does the Business Logic Layer handle View Models in MVC?

删除回忆录丶 提交于 2020-01-06 22:28:08

问题


I have an application with 4 projects

  • Presentation

  • BLL

  • Models

  • DA

Should the BLL be passing and retrieving View Models to and from the Presentation Layer. (And handle all mapping)

Or rather should it only deal with Domain Models and let the Presentation Layer (Controller) handle all mappings.

Thanks


回答1:


There is nothing absolute about your development approach. you could choose what suits you in any case. But you should consider your future maintenance and extension possibilities when you choose you approach. Based on details you provided, I think you should consider some issues:

  • User input verification: verification on user input isn't part of you BLL. So if you connect you presentation to BLL, you will mix both and it makes it hard to manage your code or "separation on concerns"
  • In mvc case you always use data annotation for presentation. Using BLL for VM probably makes it hard to use them.
  • On presentation layer, you need tools like CSS and Jquery. Using them with BLL, probably makes your code very messy and hard to maintain later.
  • For any even minor change on your presentation, you need to change your BLL which is against all principals!.
  • It will be hard to provide services like WebApi for clients, if you intermingled you BLL with presentation.
  • BLL access from views, makes life easier for hackers!.

and lots more!.



来源:https://stackoverflow.com/questions/35306301/does-the-business-logic-layer-handle-view-models-in-mvc

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