Building Intelligent, Rule-Based Applications?
Donald Hughes asks: "What are good approaches for building intelligent, rule-based applications? In particular, I typically build ASP.Net applications. I came across P#, which translates Prolog into C#. I also came across NxBRE, which touts itself as the first open-source rules engine for the .Net platform. Currently, the intelligence in my applications consist of data stored in the database, which is either processed in T-SQL or in a C# class using linear conditional logic. This approach works fine to a point, after which the complexity of the if/then statements becomes extremely difficult to manage. This is especially problematic when returning to a project after several months of not looking at it, or when someone needs to be introduced to it for the first time. Does anyone have some helpful advice?"
Maybe make another data structure which contains a list of constraints, sort of like a data representation of all of those if-then-else statements. You can customise the data structure and make it as simple or as complicated as it needs to be to support the processing of those rules.
:)
That way, you can also associate comments and descriptions with those rules which might make it easier to come back to or introduce new people to. Especially if you represent the rules in a particularly user-friendly way (eg. In a database or an XML file as opposed to a binary dump of your data structure into a file) then you allow for simple editting of these constraints using existing tools, and as an added bonus, avoid the need for a recompile each time the constraints need to be changed.
Of course, the disadvantage of this approach is slower execution of your code. If that is a priority then this wouldn't be the best idea