分层架构和静态方法
我需要关于我计划实施的三层架构的建议。
场景
正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在寻找同样的答案。也就是说,应用程序设计“是否有标准方法/最佳实践”。我的问题与 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.