简体   繁体   English

业务层设计

[英]Design of Business Layer

We are currently revamping our architecture and design of application. 我们目前正在改进我们的架构和应用程序设计。 We have just completed design of Data Access Layer which is generic in the sense that it works using XML and reflection to persist data. 我们刚刚完成了数据访问层的设计,它是通用的,因为它使用XML和反射来保存数据。

Any ways now we are in the phase of designing business layer. 现在我们处于设计业务层的阶段。 We have read some books related to Enterprise Architecture and Design so we have found that there are few patterns that can be applied on business layer. 我们已经阅读了一些与企业架构和设计相关的书籍,因此我们发现可以在业务层上应用的模式很少。 Table Pattern and Domain Model are example of such patterns. 表格模式和域模型是此类模式的示例。 Also we have found Domain Driven Design as well. 我们也发现了域驱动设计。

Earlier we decided to build Entities against table objects. 之前我们决定针对表对象构建实体。 But we found that there is difference in Entities and Value Objects when it comes to DDD. 但是我们发现实体和价值对象在DDD方面存在差异。 For those of you who have gone through such design. 对于那些经历过这种设计的人。 Please guide me related to pattern, practice and sample. 请指导我关于模式,练习和样本。

Thank you in advance! 先感谢您! Also please feel free to discuss if you didn't get any point of mine. 如果你没有得到我的任何观点,请随时讨论。

@Adil, this is not an answer to your original question, but I would advise you to revise your decision to roll your own data access layer. @Adil,这不是你原来问题的答案,但我建议你修改你推出自己的数据访问层的决定。 You note that you'd like to go to NHibernate: just do it now. 你注意到你想去NHibernate:现在就去做吧。

IMO, writing an ORM is a waste of time unless you have some very specific restrictions. IMO,写一个ORM是浪费时间,除非你有一些非常具体的限制。 There are a wealth of options out there, with hundreds of hours of effort poured into them already. 那里有很多选择,已经有数百小时的努力。 Leverage it! 利用它! LINQ2SQL, Entity framework, NHibernate, Subsonic, LLBLGen are all good, and there are more out there. LINQ2SQL,实体框架,NHibernate,Subsonic,LLBLGen都很好,还有更多。

Note too that if you roll your own you won't get to use the goodness that is LINQ without a lot of effort. 还要注意,如果你自己动手,你就不会花费很多精力来使用LINQ的优点。

As far as layering goes, try not to go nuts: keep the number of layers in check and concentrate instead on building a worthwhile interface between them to guard against your abstractions leaking. 就分层而言,尽量不要坚持:保持层数,并集中精力在它们之间建立一个有价值的界面,以防止你的抽象泄漏。

I've seen a number of very "patterned", beautifully layered projects that in use end up with logic everywhere and persistence abstractions leaked all over the place. 我已经看到了一些非常“模式化”,精美分层的项目,这些项目在使用中最终到处都是逻辑,并且持久性抽象在整个地方泄露。 Keep it simple! 把事情简单化!

CSLA.NET非常适合作为业务层的基础。

@Adil, @Adil,

I'm not very experient user, anyway, this is the kind of model I'm using (also with NHibernate). 我不是很有经验的用户,无论如何,这是我正在使用的那种模型(也与NHibernate一样)。

GUI - with all the web forms and so on BLL - The catalogs that are responsible for creating instances of new objects DAL - The place where classes responsible for interaction with NHibernate are implemented. GUI - 包含所有Web表单等BLL - 负责创建新对象实例的目录DAL - 实现负责与NHibernate交互的类的位置。 The NHibernate mapping files are here. NHibernate映射文件在这里。

Model - Class Library that is used by the BLL and DAL for data transfer object between. Model - BLL和DAL用于数据传输对象的类库。

Different patterns are used. 使用不同的模式。 For example, the BLL and DAL have a Factory class that allow access to an interface. 例如,BLL和DAL具有允许访问接口的Factory类。 The catalogs are Singleton classes. 目录是Singleton类。 All of the catalogs are accessible using a master Singleton class representing my business logic top object (for example "Enterprise" => "Enterprise.PeopleCatalog". 可以使用表示我的业务逻辑顶级对象的主Singleton类来访问所有目录(例如“Enterprise”=>“Enterprise.PeopleCatalog”。

Anyway, hope it helped... 无论如何,希望它有所帮助......

@AngryHacker, thanks for the tip, could you give an example of CSLA.NET? @AngryHacker,感谢您的提示,您能举一个CSLA.NET的例子吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM