为什么我们需要一个商业逻辑层? [英] Why do we need a business logic layer?

查看:133
本文介绍了为什么我们需要一个商业逻辑层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发使用Web服务ASP.net应用程序。有直接没有数据基本连接从我的应用程序 - 所有的活动都使用Web服务来处理。

I'm developing ASP.net application which use web services. There are no data base connections directly from my application -- all the activities are handled using web services.

在UI层我能做到使用LINQ code几行数据自定义和验证。什么缺点,如果我不为我的应用程序有一个业务层?

In the UI layer I can do the data customizations and validations using a few lines of Linq code. What are the drawbacks if I don't have a business layer for my application?

推荐答案

把所有的验证和业务逻辑放到了自己的层是很好的原因是多方面的。

Putting all your validation and business logic into its own tier is good for many reasons.


  1. 它使所有本地化的业务逻辑,并在同一个地方。未来的变化将是作为一个结果要容易得多。

  1. It keeps all of your business logic localized, and in one place. Future changes will be much easier as a result.

它可以让你更轻松地进行单元测试你的业务逻辑。这是一个大的。这是非常困难的编写自动化单元测试对你的业务逻辑,如果这code是紧耦合到您的网页或窗口的形式。

It allows you to more easily unit test your business logic. This is a big one. It's very difficult to write automated unit tests against your business logic if this code is tightly coupled to your web page, or windows form.

它使您的用户界面更苗条。

It keeps your UI much slimmer.

另请参阅:单一职责原则(简单地说,你的UI类应该做UI的事情,而不是业务逻辑事情)。

See also: single responsibility principle (in a nutshell, your UI classes should do UI things, not business-logic things).

这篇关于为什么我们需要一个商业逻辑层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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