这被称为三层建筑师吗? [英] Is This Called 3-Tiers Architect ?

查看:104
本文介绍了这被称为三层建筑师吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我和他的一位同事谈了他的asp.net应用程序代码。



我想知道我应该在BAL(BLL)中声明数据库相关的任务,因为我的伙伴,他声明了他的t-sql,对象的属性及其INSERT,UPDATE ...他的BAL课程中的方法。然后他只将查询作为参数传递给DAL执行。

他的DAL只有执行该查询并返回的任务。



在我看来,对于每个对象都应该有反应BAL和DAL。



所以,我想问哪一个会给它带来最大的好处,或者没有一个:)?



我们只是初级程序员。

解决方案

不!

数据库任务(包括SQL)应该在DL中,而不是BL。



3层模型的部分想法是你可以提取层和螺栓一个新的,不以任何方式影响其他人。如果通过将数据相关任务(包括准备SQL)移动到BL中来限制此操作,那么您将限制DL可以替换的内容。例如,如果您在BL中使用MsSQL特定功能,则当公司切换到MySql,SQLite,SQLCE,CSV文件或某些未来技术时,您无法替换DL。



图层应该彼此独立!


Hi there ! I've had a big talk with one of my colleague on his asp.net application code.

I wonder about should I declare the database related tasks in the BAL ( BLL ) because my mate, he declares his t-sql, object's properties and its INSERT, UPDATE...method in his BAL class. And he only then pass the query as argument to the DAL for executing.
His DAL only has a duty that execute that query and returns.

In my point of view, for every object there should be corresponsive BAL and DAL.

So, I would like to ask which one will give it the most benefit or none of them :) ?

We're just Junior programmer.

解决方案

No!
Database tasks (including SQL) should be in the DL, not the BL.

Part of the idea of the 3 Tier Model is that you can extract a layer and bolt a new one in without affecting the others in any way. If you limit this by moving data related tasks (including preparing SQL) into the BL then you are restricting what the DL can be replaced with. FOr example, if you use MsSQL specific functions in your BL, you can't replace the DL when the company switches to MySql, SQLite, SQLCE, CSV files, or some future technology.

The layers are supposed to be independent of each other!


这篇关于这被称为三层建筑师吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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