n层方法 [英] n-layer approach

查看:70
本文介绍了n层方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要正确的事。但首先,我要承认。

我现在已经构建了一些ASP.NET站点(2.0版),它们都运行良好。

但是,我(以及这​​里的忏悔)在每个中使用了SqlDataSource,其中一个是



我读了很多博客和文章告诉我这只是,好吧,

有罪。我必须采用n层/层方法,它使用数据

访问层和业务逻辑层。我已经研究了这个,对我而言,

看起来像是一大堆额外的工作。


我建立的网站类型一般

中小型公司的在线杂志和网站。我对参与

" enterprise"不感兴趣。应用程序,我自己工作,所以我不必担心

关于需要在

隔离的网站上工作的立方专家。此外,这些网站永远不会更改数据库,也不需要前端的窗口形式。如果他们中的任何一个每月获得20,000页的印象,

主人会很高兴。 (实际上,其中一个获得1,000,000一年

)。


其中一个网站是从传统ASP迁移,导致90%

减少代码行数。对我而言,这似乎可以减少错误的90%b / b
,但是,我承认错过了这一点。


如果我是愤世嫉俗的类型,我可能会发现自己认为在某些方面蔑视SqlDataSource的蔑视是恐惧的结果。使用

它,我可以在四分之一的时间内构建一个网站,它使用经典的ASP构建了类似的东西,而且它是,嗯,嗯。 ..很简单。

我可以看到它的简单性将允许一大堆人在商业上建立

网站,他们可能没有找到它如此简单的脚本或

ASP.NET 1.x,这意味着Web开发市场将变得更具竞争力。


但是,我不认为自己是愤世嫉俗的,因此必须要错过

重要的事情。谁能告诉我它是什么?我为什么要采用n层方法?

谢谢


Mike

解决方案

你好


你应该使用nTier

Applcations有很多原因,但不是所有这些都涉及企业应用程序

和服务器负载。但是要简单的脚踏实地地解决问题

和分离代码重用的资源。

让我们看看这两个例子:


1.示例一就像为什么使用存储过程

或为什么甚至使用Sql2005-Express而不能访问的问题。答案很简单:

a)所以我可以分配我的工作,这样一个人可以工作并帮助我完成数据库的设计而不依赖于他,b )如果这是一个带有SP的错误

,我们知道这是一个小问题或没有工作的SP问题。


2.代码重用,你说你写了很多网站,我想其中大部分网页

都有tblArticle和tblForum等等,或简而言之,就像

BeerHouse一样。示例有许多有用的模块,您可以重用它们。相同的

在您的应用程序中,您编写的多个模块很多次。并且你知道

,重用安全组件或

论坛组件.....等等,不是更简单。


....这两个非企业相关样本的足够好的例子

哪些可以促使你重新考虑所有这些?


-------------------------------------------

×?×? ×A×?×?×?×? ×?×? ×¢×?ר×? ×?×?,×?×*×? ×?×|×?×¢"×?×?"


如果我的答案有所帮助,请按是。吼叫


Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/

" Dotnet"写道:


我想这样的正确的事情。但首先,我要承认。

我现在已经构建了一些ASP.NET站点(2.0版),它们都运行良好。

但是,我(以及这​​里的忏悔)在每个中使用了SqlDataSource,其中一个是



我读了很多博客和文章告诉我这只是,好吧,

有罪。我必须采用n层/层方法,它使用数据

访问层和业务逻辑层。我已经研究了这个,对我而言,

看起来像是一大堆额外的工作。


我建立的网站类型一般

中小型公司的在线杂志和网站。我对参与

" enterprise"不感兴趣。应用程序,我自己工作,所以我不必担心

关于需要在

隔离的网站上工作的立方专家。此外,这些网站永远不会更改数据库,也不需要前端的窗口形式。如果他们中的任何一个每月获得20,000页的印象,

主人会很高兴。 (实际上,其中一个获得1,000,000一年

)。


其中一个网站是从传统ASP迁移,导致90%

减少代码行数。对我而言,这似乎可以减少错误的90%b / b
,但是,我承认错过了这一点。


如果我是愤世嫉俗的类型,我可能会发现自己认为在某些方面蔑视SqlDataSource的蔑视是恐惧的结果。使用

它,我可以在四分之一的时间内构建一个网站,它使用经典的ASP构建了类似的东西,而且它是,嗯,嗯。 ..很简单。

我可以看到它的简单性将允许一大堆人在商业上建立

网站,他们可能没有找到它如此简单的脚本或

ASP.NET 1.x,这意味着Web开发市场将变得更具竞争力。


但是,我不认为自己是愤世嫉俗的,因此必须要错过

重要的事情。谁能告诉我它是什么?我为什么要采用n层方法?

谢谢


Mike


还没有足够的理由让我重新思考。我专门使用SP,因为我不想看到我页面中的所有SQL,而且我自己工作。我将

调查Beerhouse样本,但重用肯定意味着强制下一个

开发采用/继承前一个的对象和属性?

如果不兼容怎么办?我是否只是继续向对象添加方法和

属性,以便我可以涵盖所有可能性?或者我通过使用基础对象添加

额外级别,然后每次创建我自己的继承




我不使用任何代码生成工具,而且对我来说,任何

开发的重要部分都是创建所有存储过程。 n层没有帮助

我在那里,不是吗?它所做的就是给我一大堆物品代码

呢?我仍然不明白这一点。


是否存在与SqlDataSource相关的服务器负载问题?


" Adlai Maschiach" ; < Ad ************ @ discussion.microsoft.com写在

消息新闻:A9 **************** ****************** @ microsof t.com ...




您应该使用nTier

应用程序的原因有很多,但并非所有这些都与企业应用程序有关。

和服务器负载但是要简单的脚踏实地地解决问题

和分离代码重用的资源。

让我们看看这两个例子:


1.示例一就像为什么使用存储过程

或为什么甚至使用Sql2005-Express而不能访问的问题。答案很简单:

a)所以我可以分配我的工作,这样一个人可以工作并帮助我完成数据库的设计而不依赖于他,b如果你的SP有一个

bug

,我们知道这是SP问题,只需要很少或没有努力。


2.代码重用,你说你写了很多网站,我猜大多数是

他们

有tblArticle和tblForum等等,或简而言之,就像



" BeerHouse"示例有许多有用的模块,您可以重用它们。

相同

在您的应用程序中,您编写的多个模块很多次。而你

知道

,重新使用安全组件或

论坛组件会不会更简单....还有更多。


...这两个非常好的非企业相关样本的例子

可以让你重新思考所有的这个?


------------------------------------ -------

?? ????? ?? ???? ??,??? ???? ??


如果我的回答对你有帮助,请按是。吼叫


Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/


" Dotnet"写道:


>我想这样的正确的事情。但首先,我要承认。
我现在已经构建了一些ASP.NET站点(版本2.0),它们都运行良好。
但是,我有(并且这里'''忏悔)在其中一个中使用了SqlDataSource
其中一个。

我读了很多博客和文章,告诉我这只是,嗯,<有罪的。我必须采用n层/层方法,该方法利用数据访问层和业务逻辑层。我研究了这个,对我来说
它似乎是一大堆额外的工作。

我建立的网站类型通常是在线杂志和网络网站
适用于中小型公司。我对参与
企业并不感兴趣。应用程序,我自己工作,所以我不必担心需要在网站的隔离区域工作的立方专家。此外,这些网站永远不会更改数据库,也不需要前端窗口。如果他们中的任何一个获得了20,000页的印象,那么所有者将非常高兴。 (实际上,其中一个获得了1,000,000个年份。)

其中一个网站是从传统ASP迁移,导致数量减少90%
代码行。对我而言,这似乎可以减少90%的错误,但是,我承认错过了这一点。

如果我是愤世嫉俗的类型,我可能会发现自己认为在某些方面蔑视SqlDataSource是因为恐惧而导致的。
使用它,我可以在四分之一的时间里建立一个网站使用经典的ASP来构建类似的东西,它是,嗯......非常简单。
我可以看到它的简单性将允许整个负载人们建立商业网站,可能没有用脚本或ASP.NET 1.x这么容易找到它,这意味着网络开发市场将变得更具竞争力。

但是,我不认为自己是愤世嫉俗的,因此必须缺少重要的事情。谁能告诉我它是什么?我为什么要采用n层方法?

谢谢



我建​​立的网站类型通常是在线杂志和网站,价格为


中小型公司。我没兴趣参与企业中的
。应用程序,我自己工作,所以我不必担心需要在网站上单独工作的立方专家




如果你不需要采用n层方法,那么就不要使用。没有必要为了技术而使用技术来实现
。关于

SqlDataSource我要说的一件事就是你的应用程序没有强类型,这是.net开发的一个角落。

。 />


I want to so the "right thing". But first, I have a confession to make.
I''ve built a few ASP.NET sites now (Version 2.0), and they all work fine.
However, I have (and here''s the confession) used the SqlDataSource in each
one of them.

I''ve read a number of blogs and articles that tell me this is just, well,
sinful. I have to adopt an n-layer/tier approach which makes use of a Data
Access Layer and a Business Logic Layer. I''ve researched this, and to me it
seems like a whole load of extra work for nothing.

The kind of sites I build are generally online magazines and web sites for
small to medium sized companies. I am not interested in getting involved in
"enterprise" applications, and I work on my own, so I don''t have to worry
about cubicled specialists needing to work on bits of the web site in
isolation. Also, these sites will never change database, nor require a
windows form front-end. If any of them get 20,000 page impressions a month,
the owner will be well pleased. (Actually, one of them gets 1,000,000 a
year).

One of the sites was a migration from classic ASP, and resulted in a 90%
reduction in the number of lines of code. To me, this seems like a 90%
reduction in the likelihood of bugs, but then, I admit to missing the point.

If I were the cynical type, I might find myself thinking that the scorn
poured on the SqlDataSource in certain quarters is a result of fear. Using
it, I can build a site in a quarter of the time that it took me to build
something similar using classic ASP, and it''s, ermmm... pretty simple to do.
I can see that it''s simplicity will allow a whole load of people to build
sites commercially, who may not have found it so easy with scripting or
ASP.NET 1.x, which means the web development market will become more
competitive.

However, I don''t consider myself cynical, and therefore must be missing
something important. Can anyone tell me what it is? Why should I be
adopting an n-layer approach?

Thanks

Mike

解决方案

Hi

There are many reasons why you should use nTier
Applcations , But not all of them relate to "Enterprise Application"
and "Server Load" but to simple down to earth bug solving
and seperation of resources for code reuse.
lets go with these two examples:

1. example one is like the question why use Stored Procedured
or why even use Sql2005-Express and not access. and the answer is simple :
a) so I can devide my work so one person whould work and help me in the
design of the database without beeing dependent of him , b) if theres a bug
with the SP , we know that it''s a SP problem with small or no effort.

2. Code reuse , you say you write many web sites , I guess that most of them
have "tblArticle" and "tblForum" and on and on, or in short , just like the
"BeerHouse" example has many usefull modules that you can be reuse . the same
is in your applications , meny modules you write so many times . and you know
by heart , wouldn''t it be simpler to reuse the security component or the
forum component..... and many more .

.... are these two good enough examples of non enterprise related samples
which can drive you to re-think about all of this ?

-------------------------------------------
×?×? ×a×?×?×?×? ×?×? ×¢×?ר×? ×?×?, ×?×*×? ×?×|×?×¢ "×?×?"

If my answer helped you please press "Yes" bellow

Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/
"Dotnet" wrote:

I want to so the "right thing". But first, I have a confession to make.
I''ve built a few ASP.NET sites now (Version 2.0), and they all work fine.
However, I have (and here''s the confession) used the SqlDataSource in each
one of them.

I''ve read a number of blogs and articles that tell me this is just, well,
sinful. I have to adopt an n-layer/tier approach which makes use of a Data
Access Layer and a Business Logic Layer. I''ve researched this, and to me it
seems like a whole load of extra work for nothing.

The kind of sites I build are generally online magazines and web sites for
small to medium sized companies. I am not interested in getting involved in
"enterprise" applications, and I work on my own, so I don''t have to worry
about cubicled specialists needing to work on bits of the web site in
isolation. Also, these sites will never change database, nor require a
windows form front-end. If any of them get 20,000 page impressions a month,
the owner will be well pleased. (Actually, one of them gets 1,000,000 a
year).

One of the sites was a migration from classic ASP, and resulted in a 90%
reduction in the number of lines of code. To me, this seems like a 90%
reduction in the likelihood of bugs, but then, I admit to missing the point.

If I were the cynical type, I might find myself thinking that the scorn
poured on the SqlDataSource in certain quarters is a result of fear. Using
it, I can build a site in a quarter of the time that it took me to build
something similar using classic ASP, and it''s, ermmm... pretty simple to do.
I can see that it''s simplicity will allow a whole load of people to build
sites commercially, who may not have found it so easy with scripting or
ASP.NET 1.x, which means the web development market will become more
competitive.

However, I don''t consider myself cynical, and therefore must be missing
something important. Can anyone tell me what it is? Why should I be
adopting an n-layer approach?

Thanks

Mike


Not enough reason for me to re-think yet. I use SPs exclusively, because I
don''t like seeing all the SQL in my pages, and I work on my own. I shall
investigate the Beerhouse sample, but reuse surely means forcing the next
development to adopt/inherit the objects and properties of the previous one?
What if they are not compatible? Do I just keep adding methods and
properties to an object so that I can cover all eventualities? Or do I add
extra levels in by using a base object and then create my own that inherits
from it each time?

I don''t use any code generation tools, and a significant part of any
development for me is creating all the stored procedures. n-layer won''t help
me there, will it? All it does is give me a whole load of objects to code
too? I still don''t get the point.

Are there server-load issues in relation to the SqlDataSource?

"Adlai Maschiach" <Ad************@discussions.microsoft.comwrote in
message news:A9**********************************@microsof t.com...

Hi

There are many reasons why you should use nTier
Applcations , But not all of them relate to "Enterprise Application"
and "Server Load" but to simple down to earth bug solving
and seperation of resources for code reuse.
lets go with these two examples:

1. example one is like the question why use Stored Procedured
or why even use Sql2005-Express and not access. and the answer is simple :
a) so I can devide my work so one person whould work and help me in the
design of the database without beeing dependent of him , b) if theres a
bug
with the SP , we know that it''s a SP problem with small or no effort.

2. Code reuse , you say you write many web sites , I guess that most of
them
have "tblArticle" and "tblForum" and on and on, or in short , just like
the
"BeerHouse" example has many usefull modules that you can be reuse . the
same
is in your applications , meny modules you write so many times . and you
know
by heart , wouldn''t it be simpler to reuse the security component or the
forum component..... and many more .

... are these two good enough examples of non enterprise related samples
which can drive you to re-think about all of this ?

-------------------------------------------
?? ????? ?? ???? ??, ??? ???? "??"

If my answer helped you please press "Yes" bellow

Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/
"Dotnet" wrote:

>I want to so the "right thing". But first, I have a confession to make.
I''ve built a few ASP.NET sites now (Version 2.0), and they all work fine.
However, I have (and here''s the confession) used the SqlDataSource in
each
one of them.

I''ve read a number of blogs and articles that tell me this is just, well,
sinful. I have to adopt an n-layer/tier approach which makes use of a
Data
Access Layer and a Business Logic Layer. I''ve researched this, and to me
it
seems like a whole load of extra work for nothing.

The kind of sites I build are generally online magazines and web sites
for
small to medium sized companies. I am not interested in getting involved
in
"enterprise" applications, and I work on my own, so I don''t have to worry
about cubicled specialists needing to work on bits of the web site in
isolation. Also, these sites will never change database, nor require a
windows form front-end. If any of them get 20,000 page impressions a
month,
the owner will be well pleased. (Actually, one of them gets 1,000,000 a
year).

One of the sites was a migration from classic ASP, and resulted in a 90%
reduction in the number of lines of code. To me, this seems like a 90%
reduction in the likelihood of bugs, but then, I admit to missing the
point.

If I were the cynical type, I might find myself thinking that the scorn
poured on the SqlDataSource in certain quarters is a result of fear.
Using
it, I can build a site in a quarter of the time that it took me to build
something similar using classic ASP, and it''s, ermmm... pretty simple to
do.
I can see that it''s simplicity will allow a whole load of people to build
sites commercially, who may not have found it so easy with scripting or
ASP.NET 1.x, which means the web development market will become more
competitive.

However, I don''t consider myself cynical, and therefore must be missing
something important. Can anyone tell me what it is? Why should I be
adopting an n-layer approach?

Thanks

Mike



The kind of sites I build are generally online magazines and web sites for

small to medium sized companies. I am not interested in getting involved
in "enterprise" applications, and I work on my own, so I don''t have to
worry about cubicled specialists needing to work on bits of the web site
in isolation.

If you don''t need an n-tier approach then don''t use one. There is no point
using technology for technology''s sake. The one thing I will say about the
SqlDataSource is that you''re applications are not strongly typed, which is
one of the corners of .net development.


这篇关于n层方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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