I saw a comparison Cool article on MSDN. A Simple Business Rules Manager. This article demonstrates how to build a simple business rules engine by entrusting, enable centralize the business rules in the application.
After reading it, I feel very practical, but this component is written by VB.NET, so I tried it over again with C #. Because I won't be VB.NET, I have encountered a lot of problems during the rewrite, huh, huh :) If there is any problem with rewriting, I hope everyone can give me: liy@lonwin.com.cn
Below I simply talk about the idea of this component, please refer to the source code and the English article mentioned above:
Business rules in many systems are always replicated everywhere, that is, the same business logic may be everywhere. For example, a typical application, there are two different forms that need to interact with the same Customer Data. For Customer Data, business logic is the same in any place, but we need to use this data in two different forms, so sometimes we need to copy compulsory logic. As shown below:
Figure 1. Duplicated Business Logic
Obviously, it is difficult to maintain such an application. Of course we can encapsulate business logic into an object, then use the same object in different form.
Figure 2. Business Logic Centralized in an Object
It is already a big progress in encapsulating business logic into an object, but this is not the most perfect. Because we can still copy business logic in the tears of this package. such as:
Figure 3. Business logic duplicated within an object
We need a simple way to centrally process these logic, whether it is using a business object or an ADO.NET object.
Figure 4. Business Logic Centralized in a Rules Manager
This will centralize business rules without worrying about copying these annoying business rules :)
C # version code: http://www.dev-club.com/upload-files/241/2415179.rar