ddossot / NxBRE

NxBRE is a lightweight Business Rule Engine (aka Rule Based Engine) for the .NET platform.
http://nxbre.dossot.net
131 stars 60 forks source link

Inference Engine: Change property of business object #3

Closed alpesh-miles closed 10 years ago

alpesh-miles commented 10 years ago

Is it possible to change property value or add new properties to business objects from RuleBase (as a part of Implication result)?

If yes, please provide sample code to achieve the same

ddossot commented 10 years ago

This can be done within a NewFactHandler in a binder: https://github.com/ddossot/NxBRE/blob/master/NxBRE3/Rulefiles/fraudcontrol.ruleml.ccb

alpesh-miles commented 10 years ago

Thanks David. I knew that I can do it from binder, but can I do that from RuleML(i.e.rulebase as a result of implication)?

ddossot commented 10 years ago

No, you can't.

One of the design decision around the inference engine is that it deals with facts only and not with any kind of object, this to keep a clear separation between the application internals and the data the engine infers upon.

One common issue this approach avoids is rules having to change because a developer refactored an object and unconsciously broke them. Since rules execute out of band, this type of errors happen easily.