Software design aspect - Rule driven vs configuration driven design

78 Views Asked by At

I want ask this question more on design perspective rather than any implementation. Lets, start with an example of a routing engine (or anything else) that can be configured using some rule engine or some configuration based way where intention behind both the ways is, for example, to lookup the destination for incoming requests.

In my point of view, rule engine is relevant when the system need to take dynamic decision on where to route any particular request, whereas configuration based systems are more performant (since they dont have rule execution overhead) if the routing logic is predefined and agnostic of incoming request data.

Any other relevant aspect or pros-cons we should consider from application designing/architecture perspective?

1

There are 1 best solutions below

0
Peter Csala On

As I stated in the comments section the question is too broad to be able to provide specific answer IMHO. So, here I can only help you by providing a bit more generic comparison and advice.

Variations

Going with your routing example the rule driven design is considered more static than the configuration driven one. Whereas rules are usually coded with imperative techniques, the configs are considered more as a declarative approach.

And there can be huge differences between dynamic approaches:

  • Are the configs editable only by service team or by a broader audience?
  • Are the configs stored in files or records?
  • Are the configs accessible via a database or via a web service?
  • Are the configs retrieved only at service start or periodically/continuously?
  • Are the changes propagated via pooling or is it push-based?
  • etc.

Comparison

Here is a small comparison which might help you during your trade-off analysis

Pros Cons
Dynamic Rule changes can be applied more quickly Harder to debug the rule resolution especially when the engine supports multi-source and override
Static Easier to verify correctness via unit tests There is a tendency that over time the engine and rules become more complex and tenant-specific

My general rule of thumb would be to stick with a simpler approach until you bump into a limitation of the given solution. Try to think about it as an iterative approach rather than building a starship from day 1.