Dofactory.com
Dofactory.com
 Back to list
Views:   7K
Replies:  1
Archived

Complex Business Rule - Custom Validation sample

Hi,

I recently purchased Design Pattern Framework 4.0.

In the document it is mentioned like
Here is an example of a more complex rule. There may be a rule that states that customers are ranked according to their recent order history. Customers with 10 or more orders over the last 3 months receive gold status, customers with 5 to 10 orders receive silver status, and customers with fewer than 5 orders are given bronze status. These statuses can be used to determine the relative priority treatment they receive when calling a 1-800 customer support number. When an order is placed, the rule in the business object re-evaluates the customer‟s ranking. These kind of rules require (in most cases) custom validation code.

Another is
In a more complex application you may have interdependent business rules encoded outside these objects (for example, if the bank account is over $5000 and more than 3 transactions have taken place in the last month, and the account holder‟s age is > 35 and is on the same job for more than 2 years, then accept the application).

Can someone guide me where and how to write above two validation in existing Design Pattern Framework 4.0.

Regards,

Hemal Shastri
Hemal Shastri, Sep 04, 2010
Reply 1
Hemal:

The logic for custom/complex business rules are placed in the Service Layer. 
If you are using the Patterns in Action application, then you would add these in the ActionService.cs file.

As an example: if you had a complex rule that would determine whether the current user can see specific orders, you would place that logic in the GetOrders method.  Since these rules are complex it is probably best to factor these out in a special private method, such as, bool IsAllowedToSeeOrder(userId, orderId).  If this method return false, then they cannot see the order.

I hope this gets you going.
Dan McMillan, Sep 06, 2010
I hate it when that happens. Write your answer in Word and then copy and paste to prevent that from happening... :-)
Jul 28, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.