[rules-users] Template Key in DSL

Michael Anstis michael.anstis at gmail.com
Tue Jan 10 04:59:00 EST 2012


I still think, in my opinion, it is worthwhile adding the ability to define
Template Keys in DSL in Guvnor.

A simple (contrived and incomplete example) DSL might be:-

[when] There is an insurance policy quote=$p : PolicyQuote( )
[when] Number of previous claims on policy is between {min} and
{max}=ClaimHistory( quote == $p, numberOfClaims >= {min}, numberOfClaims <
{max} )
[then] Set insurance premium load factor to {loadFactor} =
$p.setLoadFactor( {loadFactor} );

A user might like to define rules using DSL for the following data set:-

0 <= claims < 1, load = 0
1 <= claims < 3, load = 10%
3 <= claims < 5, load = 15%
etc.

This can be accomplished with a Template or Decision Table using DRL terms
but as yet, in Guvnor, not DSL.

Obviously it can be achieved from a developers perspective using Drools
Expert as demonstrated.

With kind regards,

Mike

2012/1/10 Wolfgang Laun <wolfgang.laun at gmail.com>

> Hi Frank,
>
> thanks for your follow-up.
>
> As much as I like source code generators, I must confess that I've come to
> dislike the generation of many almost identical chunks, e.g., varying only
> in literals.
>
> This means that using templates without an "if" in the available macro
> language is a "weak" tool. Consequently, this triple layering isn't on my
> "tops" list.
>
> Basically, I agree with your assessment, the only caveat being the level
> of complexity and extend that is convenient to achieve with a DSL.
>
> Regards
> Wolfgang
>
>
>
> On 9 January 2012 17:08, FrankVhh <frank.vanhoenshoven at agserv.eu> wrote:
>
>> Hi,
>>
>> Sorry to have kept you waiting.
>>
>> If you use plain DRL, you have 1 source of information. If you use DSL,
>> you
>> add an extra source of information by inserting the data in it. Adding DSL
>> on top of that, adds a third source of information in the form of a
>> vocabulary.
>>
>> In theory, the more disperse your information, the more difficult it will
>> be
>> to maintain.
>>
>> Until now, I debugged all templates in the same way. Expand them all
>> completely and have them outputted to a real DRL file. Than, debug the
>> outputted file and make corrections in your template accordingly. Here,
>> imho, there is not much difference in a DSLR template and a DRL template,
>> provided that you have a stable DSL. This is not a debugging method that I
>> particullary like, but it gets the job done.
>>
>> If you assess the difference between a DSLR and a DRL template, the only
>> differentiator is the DSL. In that case it comes down to the question
>> whether you have a stable DSL or not. If your DSL is mature, I would
>> prefer
>> DSLR over DRL for reasons of understandability to non-technical users.
>> Unless your template is meant to be hidden from the user.
>>
>> Regards,
>> Frank
>>
>>
>> laune wrote
>> >
>> > OK, thanks for the confirmation.
>> >
>> > Do you have any comments w.r.t. to usability during development
>> > (debugging?!) and maintenance? The example is simple enough, but what's
>> > your feeling?
>> >
>> > -W
>> >
>> > On 6 January 2012 08:46, FrankVhh &lt;frank.vanhoenshoven@&gt; wrote:
>> >
>> >>
>> >> laune wrote
>> >> >
>> >> > What I suggested is a non-standard way of rule authoring, and I just
>> >> think
>> >> > that it is possible - I've never tried it.
>> >> >
>> >>
>> >> This should work. I tried it once with Drools 5.0, so I assume it is
>> >> still
>> >> OK.
>> >>
>> >> http://drools.46999.n3.nabble.com/file/n3637269/voc.dsl voc.dsl
>> >> http://drools.46999.n3.nabble.com/file/n3637269/Sample.dst Sample.dst
>> >> http://drools.46999.n3.nabble.com/file/n3637269/DroolsTest.java
>> >> DroolsTest.java
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://drools.46999.n3.nabble.com/Template-Key-in-DSL-tp3634710p3637269.html
>> >> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users at .jboss
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >
>> > _______________________________________________
>> > rules-users mailing list
>> > rules-users at .jboss
>> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >
>>
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/Template-Key-in-DSL-tp3634710p3644953.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120110/73d2116b/attachment.html 


More information about the rules-users mailing list