Skip to content

Commit 1e65eaf

Browse files
authored
Fix/docs (#197)
* Added performance test * Fix linting * Added usecase to the README.md and fixed Retract function description that miss explain its proper behavior
1 parent 6681021 commit 1e65eaf

File tree

2 files changed

+62
-5
lines changed

2 files changed

+62
-5
lines changed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,65 @@ By using Rules, you create a repository of knowledge (a knowledge base) which is
108108

109109
Since business rules are actually treated as data. Adjusting the rule according to business dynamic nature become trivial. No need to re-build codes, deploy as normal software development do, you only need to roll out sets of rule and apply them to knowledge repository.
110110

111-
### Docs
111+
## Use Cases
112+
113+
The following cases are better solved with a rule-engine.
114+
115+
1. An expert system that must evaluate facts to provide some sort of real-world
116+
conclusion. If not using a a RETE-style rule engine, one would code up a
117+
cascading set of `if`/`else` statements and the permutations of the
118+
combinations of how those might be evaluated would quickly become impossible
119+
to manage. A table-based rule engine might suffice but it is still more
120+
brittle against change and is not terribly easy to code. A system like Grule
121+
allows you to describe the rules and facts of your system, releasing you from
122+
the need to describe how the rules are evaluated against those facts, hiding
123+
the bulk of that complexity from you.
124+
125+
2. A rating system. For example, a bank system may want to create a "score" for
126+
each customer based on the customer's transaction records (facts). We could
127+
see their score change based on how often they interact with the bank, how
128+
much money they transfer in and out, how quickly they pay their bills, how
129+
much interest they accrue earn for themselves or for the bank, and so on. A
130+
rule engine is provided by the developer and the specification of the facts
131+
and rules can then be supplied by subject matter experts in the bank's
132+
customer business. Decoupling these different teams puts the responsbilities
133+
where they should be.
134+
135+
3. Computer games. Player status, rewards, penalties, damage, scores and
136+
probability systems are many different examples of where rule play a
137+
significant part of nearly all computer games. These rules can interact in
138+
very complex ways, often times in ways that the developer didn't imagine.
139+
Coding these dynamic situations in a scripting language (e.g. LUA) can get
140+
quite complex, and a rule engine can help simplify the work tremendously.
141+
142+
4. Classification systems. This is actually a generalization of the rating
143+
system described above. Using a rule engine, we can classify things such as
144+
credit eligibility, bio chemical identification, risk assessment for
145+
insurance products, potential security threats, and many more.
146+
147+
5. Advice/Suggestion system. A "rule" is simply another kind of data, which
148+
makes it a prime candidate for definition by another program. This program
149+
can be another expert system or artificial intelligence. Rules can be
150+
manipulated by another system in order to deal with new types of facts or
151+
newly discovered information about the domain which the rule set is intending
152+
to model.
153+
154+
There are so many other use-cases that would benefit from the use of
155+
Rule-Engine. The above cases represent only a small number of the potential.
156+
157+
However it is important to state that a Rule-Engine not a silver bullet, of
158+
course. Many alternatives exist to solve "knowledge" problems in software and
159+
those should be employed when they are most appropriate. One would not employ a
160+
rule engine where a simple `if` / `else` branch would suffice, for instance.
161+
162+
Theres's someting else to note: some rule engine implementations are extremely
163+
expensive yet many businesses gain so much value from them that the cost of
164+
running them is easily offset by that value. For even moderately complex use
165+
cases, the benefit of a strong rule engine that can decouple teams and tame
166+
business complexity seems to be quite clear.
167+
168+
169+
## Docs
112170

113171
Grule's Documentation now viewable in ViewDocs. [http://hyperjumptech.viewdocs.io](http://hyperjumptech.viewdocs.io/grule-rule-engine)
114172

docs/Function_en.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ rule CheckStartTime "Check device's starting time." {
149149

150150
### Retract(ruleName string)
151151

152-
`Retract` will remove the specified rule from the next cycle evaluation. If a
153-
rule is retracted its `when` scope will not be evaluated on the next immediate
154-
cycle after the call to `Retract`. Before the following cycle, all retracted
155-
rules will be restored.
152+
`Retract` will exclude the specified rule from the subsequent cycle evaluations. If a
153+
rule is retracted its `when` scope will not be evaluated on the next cycles after the call to `Retract`.
154+
The engine will automatically resets all rule back inplace when it start again from the beginning.
156155

157156
#### Arguments
158157

0 commit comments

Comments
 (0)