建议在业务层和静态类中使用system.web.dll引用 [英] Is this recommended to use system.web.dll reference in business layer and static class

查看:74
本文介绍了建议在业务层和静态类中使用system.web.dll引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的理解,在Web项目的数据和业务层中使用System.Web引用并不是理想的方法。



在静态类中使用它也不是一个好主意,它应该在控制器级别。



寻找推荐和理想的方法。



我尝试过:



寻找推荐和理想的方法。

As per my understanding, it is not the ideal approach to use System.Web reference in the data and business layer of the web project.

It is also no good idea to use it in a static class, it should be at Controller level.

Looking for recommendation and ideal approach around it.

What I have tried:

Looking for recommendation and ideal approach around it.

推荐答案

为什么要使用演示文稿业务层或数据层中的层代码?

想一想:三层模型的想法是关注点分离:您可以使用现有的SQL Server数据源并将其替换为MySQL源代码通过交换数据层,其他两个根本不需要改变。



如果你开始在表示层之外引用表示代码,你就是打破分离,因为你不能在不改变BL的情况下换掉PL。



这意味着你的整个设计都有缺陷。
Why would you use presentation layer code in business or data layers at all?
Think about it: the idea of the three layer model is separation of concerns: you can take an existing SQL Server data source and replace it with a MySQL source by "swapping out" the data layer and the other two don't have to change at all.

If you start referencing presentation code outside the presentation layer, you are breaking the separation because you can't swap out the PL without changing the BL.

And that means your whole design is flawed.


这篇关于建议在业务层和静态类中使用system.web.dll引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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