Auditor or Overrides in Partial Entity Classes?

Posts   
 
    
mkuzma
User
Posts: 11
Joined: 25-Feb-2011
# Posted on: 20-May-2011 23:01:39   

Hello,

I am curious on how people feel about using Auditors vs. Overriding the various methods in their Partial Entity classes? We are trying to standardize how we should best handle executing business rules, particularly during Inserts and Updates of data. Are there any guidelines, writeups, or general rules for this subject?

Thank you.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-May-2011 23:51:41   

Here are some thoughts about it. In general this depends upon how your architecture looks like. First lets see your options:

A. Using auditing methods inside entities (CUSTOM_CODE_REGION or partial classes).

B. Using an Auditor object and assign it when you create an entity (Initialize method)

C. Using an Auditor object and use DependencyInjection to auto inject it into the entity instances.

So, if for instance, your database generic project has a lot of business rules, maybe it's appropriate to put the auditor methods there as well. This applies more naturally if you are using SelfServicing template set.

If you have some Manager classes that perform all business rules, maybe would be more convenient to use an Auditor class. You may assign it or un-assign it depending upon some BL rules.

If you have some Manager classes but they are not aware of any auditing mechanisms and you want to isolate that, then it's more likely you have to use Auditor classes with Dependency Injection. This way your BL is not aware of it, and you can plug-unplug the auditor, or change it, or extend it, without affecting your other modules.

David Elizondo | LLBLGen Support Team
mkuzma
User
Posts: 11
Joined: 25-Feb-2011
# Posted on: 21-May-2011 01:16:41   

Thanks for the reply.

It seems like the real benefit to the auditors is to encapsulate saparate logic based on one or more conditions. That is a great benefit for those who need it. I think I have our answer, Auditors should be used when you may or do need to apply separate rules for different scenarios, otherwise, override the methods in the Partial Entity Class.

Thanks again.