Hello,
In my company we are planning to use Drools a BRE for couple of projects. Now we trying to define some best-practices.
My question is what should be and shouldn't be done inside a Rule Condition/Consequence.
Given that we can write Java directly or call methods (for example From a Global object in the Working Memory).
Example. Given a Rule that evaluates a generic Object (e.g. Person) have property set to true. Now, that specific propertie can only be defined for that Object going to the database and fetching that info. So we have two ways of implementing that:
Alternative A:
Go to the database and fetch the object property (true/false, a code)
Insert the Object in the working memory
Evaluate the rule
Alternative B:
Insert a Global Object that has a method that connects to the database and check for the property for the given object.
Insert the Object to eval in Working Memory
In the rule, call the Global Object and perform the access to the database
Which of those is considered better? I really like A, but sometimes B is more straightforward, however what would happen if something like a Exception from the Database is raised?
I have seen the alternative B implemented in the Drools 5.0 Book from Packt Publishing,however they are doing a mocking and they don't talk about the actual implications of going to the database at all.
Thank you,