Reputation: 1118
I am thinking about a method to handle the data more efficiently. Let me explain it:
Currently, there is a class, called Rules
, it has a lot of member functions, like Rules::isForwardEligible()
, Rules::isCurrentNumberEligible()
....So these functions are used to check the specific situations (when other process call them), all of them return bool value.
In the body of these functions are if
s which will query the DB to compare data, finally return turn or false.
So the whole thing is like if(Rules::isCurrentNumberEligible())
--->Check content in Rules::isCurrentNumberEligible()
--->if(xxxx)
(xxxx will be another function again, query DB), I think this kind way is not good. I want to improve it.
What I am imagining, is to use less code but query more for the information.
So I can query in the first step if(Rules::isCurrentNumberEligible())
, I can set different tables for query, so the things like if(xxx){if(xx){if(xx)....}}
will be less. A solutions is to build a class whose role is like a coordinator, ask him each time for different querys. Is it suitable?
I am not sure it is a good way to control this, or may be there are some good solutions aside. Please help me, thanks!
Upvotes: 1
Views: 238
Reputation: 11322
The classical algorithm for rule-based systems is the RETE algorithm. It strives to minimize the number of rules to be evaluated. The trick is that a re-evaluation of a rule does not make sense unless at least one related fact has changed.
In general, those rules should be queried first which promise maximum information gain. This helps to pin-down the respective case in as few questions as possible. A physician in differential diagnosis would always order his/her questions from general to specific. In information theory this is called the principle of maximum entropy.
Upvotes: 1