Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
3-tier question
Message
From
20/02/2003 04:18:19
 
 
To
19/02/2003 13:18:02
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
Miscellaneous
Thread ID:
00754835
Message ID:
00755374
Views:
13
Thanks Bob, that's exactly what I needed to know.

Kev

>>>When you design the BO, put code to validate the record before the save is committed. That way, no matter how many places can this save be called from, it will execute the same validation every time. Biz rules that are App specific I would not place in the SP of the DB, other validations that are not App specific for Ex. 'Sex' field accepting only 'M or F' can be enforced at the DB level.
>>
>>Yes, but in what form are the BR's, class? method? various methods in a class? methods in the BO?
>>
>>Thanks
>>Kev
>
>A BusinessRule class, in the framework I am used to running is a fairly simple class. The main item is an Execute() method. This is the method that you implement your rules in, returning a .t. if the rule was passed, and a .f. if the rule fails. The rule might also have a cErrorMessage property to contain the message that you want displayed to the user if the rule is violated.
>
>Now, your BusinessObject will have a Rules (or BusinessRules) property that is a collection of business rules. Perhaps you can have a template method called AddBusinessRules() that is called from the BO init method. In the AddBusinessRules() method you would write code like:
>
>This.AddBusinessRule('MaximumCreditLimitRule')
>
>The AddBusinessRule method of your BizObj would instantiate the class "MaximumCreditLimitRule" and add it to the BusinessRules collection.
>
>Finally, in your Save() method you would first call the Validate() method. In the validate method you would loop through the BusinessRules collection calling each ones Execute method. You might want to send the execute method a reference to the bizobj that it is being called from.
>
>*******
>To extend this you could provide a way to tie a business rule to a specific field/property of the business object. This would perhaps allow you to have something to call from your UI controls in the lost focus to verify the data entry and give immediate feedback.
>
>There are more possiblities to expand this. You could also support business rules for adding new records, and even for navigation. This may allow you to use busiess rules to enforce some type of role based security.
>
>I think this is a pretty common pattern, perhaps you could publish it on the Wiki somewhere.
>
>BOb
Previous
Reply
Map
View

Click here to load this message in the networking platform