Rule Engine – Inheritance

AX 2012 doesn’t use inheritance a lot. Classes can inherit, but tables cannot, and I don’t think forms can (or rather, all forms inherit from ObjectRun). There is no inheritance for enums or Reports or anything except classes. But my rule engine is a class, so I have to decide whether to use inheritance or abstain.

The downside to inheritance is that you end up with two classes, and sometimes you’re not going to be able to know or remember which methods are in each class. You’ll have to switch between the classes, for instance if you’re in the child class and it references a method that’s in the parent class only and not overridden. The longer the inheritance tree, the more difficult it can be to determine which methods will be run.

But certainly in this situation, I feel the rewards outweigh the costs. It allows me to make a clear delamination in my project between functionality that’s basic to any rule engine that makes the rule engine work (ie, math, string functions), and logic that’s specific to my data structure. When we upgrade to 365 – a project that’s starting in a month or so – I’d expect the base rule engine functionality to remain the same, while the subclass will need to change to get Job data from the cloud.

Inheritance is specified with the ‘extends’ keyword.

Leave a comment