Git Product home page Git Product logo

Comments (6)

Clayton7510 avatar Clayton7510 commented on May 20, 2024

Having an option where NEXT and BREAK don't have to be returned also allows for other (non procedural) rules chaining options. Although I think RuleBook will always have sequential chaining at its core, the focus has to be on an intuitive and flexible interface. That was the whole reason for RuleBook in the first place -> something that could be picked up and used effectively in an hour or two (at most).

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 20, 2024

I also think that there should probably be an easier way to extract facts in the DSL. Using Fact objects is nice since it guarantees a reference - Facts hold references, and even do cool stuff like keep up with changes to immutable objects (e.g. Strings). But you shouldn't always have to know they are there or work directly with Fact objects or the FactMap object in the DSL. Modifying the given() is a great first step. But the next step is making Facts transparent in their usage in Rules.
What about something like the following?

StandardRule.create().given("hello", "Hello").given("world", "World").when(f -> true).using("hello").then(System.out::println).using("world").then(System.out::println); //this would print "HelloWorld"

or this would also work

StandardRule.create().given("hello", "Hello").given("world", "World").using("hello").then(System.out::println).using("hello").then(System.out::println); //this would print "HelloWorld"

or in a RuleBook (where Facts are automagically supplied to Rules)

StandardRule.create().using("hello").then(System.out::println).using("world").then(System.out::println); //this would print "HelloWorld"

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 20, 2024

It looks like doing the above stuff will break the existing DSL, which I am not a huge fan of doing. But I do think it will yield a nicer to work with DSL and a more rich language.
This would not affect POJO rules, however.

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 20, 2024

The DSL is mostly intact. All the old stuff will still work with one exception: then methods can't return anything. In lieu of having to return RuleState from a then method, the new stop method is introduced. By chaining the stop verb, it signals the rule to break the rule chain after the then action is executed, which also means the when condition must be true for the rule chain to be broken.

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 20, 2024

Branch Issue36_SyntacticSugar contains the completed and working code. All tests are passing.
All that's left now to ensure that coverage is up to snuff given the new changes and JavaDocs are updated appropriately.

from rulebook.

Clayton7510 avatar Clayton7510 commented on May 20, 2024

These enhancements have been pushed out to 0.3.5-SNAPSHOT and merged into the develop branch.

from rulebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.