Friday, November 27, 2009

An issue of Context…

When creating a rule/logic/workflow engine there are various things that need to be considered in it’s architecture.

One of the most overlooked aspects of such systems is that of the CONTEXT in which a rule is run, and how it affects what a rule can do.

To elaborate a little more, rules normally know nothing of the environment that they run in, rules just execute logic based upon data that should be available when the rule is evaluated for its result. (a result is normally a logical true/false, but it can be other values and data types depending on its usage and context).

So what do I mean by Context, quite simple the context for an executing rule is the environment that it runs in.

A context normally defines what data is available to a rule for example:

    • Global Values
    • Results of nested logic that is used in the rule
    • System data that is applicable to the rule being evaluated
    • Functions or other rules that can be called by the rule

A rules engine when it is instantiated/run should go through the following processing steps:

  • Setup context for the rule (normally defined by a flag or driven by a workflow system)
  • Execute a rule or batch of rules in context
  • Tear down context (sometimes a context is persisted depending on the type of rule logic and system it is in)

Later on, I will be creating a simple logic/rule engine that conforms to the above and deals with the issues in creating and synchronizing a context and its data.

I hope this has been at least a little helpful, soon the real fun and more technical stuff will be started.

No comments: