分层架构和静态方法

发布于 2024-09-01 06:29:23 字数 417 浏览 6 评论 0原文

我需要关于我计划实施的三层架构的建议。

场景

正在 ASP.NET c# 3.5 环境中工作。

DLHelper:从数据库获取数据的方法。

DAL:包含借助 DLHelper 类从数据库收集数据的方法。该层中的大多数方法不引用任何页面级对象,因此可以声明为静态。

BL :与 DAL 层相同,大多数方法不引用任何页面其他页面级对象,因此可以声明为静态。

UI 层:根据上述场景,UI 层对 BL 层的调用类似于

BLClass.Method -> DALClass.Method

问题 我想知道这是一种标准化的方法吗?根据与同事的讨论,我们应该有相应的 BL/DAL 层对象。但我仍在寻找更有说服力的答案。

I need suggestion for three layered architecture I am planning to implement.

Scenario

Am Working in ASP.NET c# 3.5 Environment.

DLHelper: Methods to get data from database.

DAL : Contains Methods which collects data from database with help of DLHelper classes. Most of the methods in this layer are not referencing any page level object, hence can be declared static.

BL : Same as DAL Layer, most of the methods are not referencing any page other page level object, hence can be declared static.

UI Layer: As per above scenario UI Layer call to BL Layer is like

BLClass.Method -> DALClass.Method

Question
I would like to know is this standardise way to do it. As per discussion with my co-worker, we should have corresponding object of BL/DAL layer. But am still looking for more convencing answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我也只是我 2024-09-08 06:29:23

我一直在寻找同样的答案。也就是说,应用程序设计“是否有标准方法/最佳实践”。我的问题与 BL 上的静态方法有关。不过,我想我不能给你一个直接的答案。

我可以告诉你,就我而言,我继续将某些类中的方法设为静态。我这样做是因为不需要实例(因为它们在 OOP 文献中被严格定义)。也就是说,不需要创建具有自己状态的对象。

“根据与我的同事的讨论,我们应该有每一层的对象”。如果您的意思是只有一个对象,那么我强烈建议您重新考虑。在大多数情况下,有多个“合作”来交付结果(当然也有例外)。

在很多情况下,“责任驱动的设计”对我来说确实很有帮助。

I was looking for the same answer. That is 'if there is a standard way/best practice' for an application design. My question had to do with static methods on the BL.I don't think I can give you a straight answer though.

I can tell you that in my case, I moved on and made the methods in some Classes static. I did that since there was no need for Instances (as they are strictly defined in OOP literature). That is, there was no need to create objects that would have their own state.

"As per discussion with my co-worker, we should have object of every layer". If you mean that there is going to be ONE object then i urge you to reconsider. In most cases there are more than one 'collaborating' to deliver a result (with exceptions of course).

The 'responsibility driven design' was and is really helpful for me in many cases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文