Business Layer
The following guidelines will help you to understand fundamental factors you must consider when designing the business layer for your application. Use these guidelines as a starting point toward understanding key concerns, such as when to use business entities, how to implement business components, and how to expose your business layer as a service. (下面的指导将帮助你理解在设计业务层时必须考虑的基础因素)
• How to implement business entities(如何实现业务实体)
If you are designing a small Web application or a service(如果是设计小型Web应用或者服务), and you want to take advantage of the disconnected behavior they provide, consider using DataSets(并且希望利用不保持连接的优势,考虑使用Dataset). If you are working with content-based applications that have few or no business rules, consider using XML(对于基于内容的应用,并且只有很少的或者没有业务规则,考虑使用XML). If you have complex business rules related to the business domain, or if you are designing a rich client where the domain model can be initialized and held in memory, consider using custom Domain Model objects(如果有业务领域内有复杂的业务规则,或者你在设计一个富客户端,它可以在初始化的时候把域模型载入内存,考虑使用自定也的域模型对象【Domain Model Objects】). If your tables or views in the database represent the business entities used by your application, consider using custom objects(如果数据库中的数据表与视图表现了应用中的业务实体,考虑使用自定义对象). If the data you are consuming is already in XML format, or if you are working with read-only documentbased data, consider using custom XML objects(如果数据已经是XML格式,或者处理只读的基于文档的数据,考虑使用自定义XML对象).
For more information, see Chapter 11, “Business Layer Guidelines.”
• How to implement business components(如何实现业务组件)
The type of business component you implement depends on your business rules(业务组件的类型依赖于业务规则). If you have volatile business rules(如果业务规则不稳定), consider storing them in a separate rules engine(考虑将这些规则存储在独立的规则引擎中). If you want your business rules to be separate from the business data(如果希望业务规则与业务数据分开), consider using business process components(考虑使用业务处理组件). If your business processes involve multiple steps with long-running transactions, consider using business workflow components(如果你的业务处理包含多步走操作与长时间运行的事务,考虑使用业务工作流组件). A well-designed business component exposes data and functionality based on how the data is used, and abstracts the underlying data store and service(一个设计很好的业务组件 基于数据如何使用 公开功能与数据,并且抽象它下层的数据存储与服务). Do not mix unrelated functionality within a business component(不要将不相干的功能混合在业务组件内); for example, do not mix data access logic and business logic within the same component(例如:不要将数据访问逻辑和业务逻辑混在同一个组件内). Consider designing consistent input and output data formats for business components(考虑为业务组件设计始终一致的数据输入/输出格式).
For more information, see Chapter 11, “Business Layer Guidelines.”
• How to design application service façades(如何设计应用服务外观)
A well-designed application service façade exposes a simple interface by encapsulating cohesive behavior that is specific to a set of related business operations(一个设计良好的应用程序服务外观会公开一个简单的接口,该接口将一系列相关的业务操作封装成cohesive behavior ). Avoid including business logic in a service interface in order to improve reusability and maintainability and reduce duplication of code(为了提高可重用性与可维护性并减少代码重复,要避免将业务逻辑包含在服务接口中). Consider using standard protocols such as the SOAP as the communication medium to ensure maximum compatibility with a range of clients(考虑使用标准协议例如SOAP作为通信介质,来确保与更多的客户端保持最大的兼容性).
For more information, see Chapter 11, “Business Layer Guidelines.”
本文提供了设计业务层的基本指导原则,包括如何实现业务实体、业务组件及应用服务外观等内容。建议根据业务需求选择合适的实现方式,如使用DataSet、XML或自定义对象等。
6124

被折叠的 条评论
为什么被折叠?



