Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Rules feature #40

Closed
yevhenii-pazii opened this issue May 23, 2016 · 3 comments
Closed

Check Rules feature #40

yevhenii-pazii opened this issue May 23, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@yevhenii-pazii
Copy link

yevhenii-pazii commented May 23, 2016

Hi guys,

I found yours project very interesting for me, but I have some suggestions for you.

  1. Sometimes it may be useful to not fire rules, but only check them like:
    boolean allRulesApplicable = ruleEngine.checkRules();
    Or return some rules result which can contain simple map (String, Boolean), where key is a Rule name and values is a "evaluate" method result. "fireRules" should return boolean or rules status.
  2. Also it may be useful in conjunction with feature above to have rules evaluator to be able check rules like:
    (RuleA and RuleB) or RuleC
  3. Maybe it will be a good idea to separate execute method from Rule itself to give additional level of abstraction. For example, if I use a CompositeRule it is possible that I want to execute a single "Job" for all contained rules. It can possibly give more flexibility with features 1 and 2.

P.S. It is possible that I understand project use cases wrong :)

Thanks in advance.

@fmbenhassine
Copy link
Member

Hi @thecederick

Thank you for these suggestions!

Sometimes it may be useful to not fire rules, but only check them

Good idea indeed. This will allow the user to do some kind of "simulation" before firing rules. I've added a method checkRules in version 2.3.0-SNAPSHOT. You can give it a try, here is an example.

Also it may be useful in conjunction with feature above to have rules evaluator to be able check rules

You can already do this: ( ruleA.evaluate() && ruleB.evaluate() ) || ruleC.evaluate() . Do you believe Easy Rules should provide a RuleEvaluator API?

Maybe it will be a good idea to separate execute method from Rule itself to give additional level of abstraction.

That was the case in the early stages of the project. We've got a separate concepts for Condition, Action and Rule. But we have decided to make a rule encapsulate the BOM, conditions and actions together as a unit.. That's easier 😉

Kind regards
Mahmoud

@fmbenhassine fmbenhassine added this to the 2.3 milestone May 24, 2016
@fmbenhassine fmbenhassine self-assigned this May 24, 2016
@yevhenii-pazii
Copy link
Author

Hi,

Thanks for the quick response!

Good idea indeed. This will allow the user to do some kind of "simulation" before firing rules. I've added a method checkRules in version 2.3.0-SNAPSHOT. You can give it a try, here is an example.

Looks pretty good for me)

You can already do this: ( ruleA.evaluate() && ruleB.evaluate() ) || ruleC.evaluate() . Do you believe Easy Rules should provide a RuleEvaluator API?

It is not always possible do it like you described, for example @Condition annotation and you do it outside of Engine.

Thank you for your project, hope to use it soon!

@fmbenhassine
Copy link
Member

Hi,

I've merged in the master branch the addition of the checkRules method in the RulesEngine API. It will be released soon in the 2.3 version.

In regards to the RulesEvaluator API, I've created a separate issue ( #42 ) and I planned to add it to the library too. Keep tuned 😄

Kind regards
Mahmoud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants