﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on The magic of boo - Flexible syntax</title><description>Joe,
  
That is because you are seeing the simplest possible example.
  
Try to imagine this on a real world system, where you may have tens or hundreds of variables.
  
In this scenario, trying to define a rigid system breaks.
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment12</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment12</guid><pubDate>Fri, 30 May 2008 17:17:56 GMT</pubDate></item><item><title>Joe Gutierrez commented on The magic of boo - Flexible syntax</title><description>You have two states for input User:
  
IsPreferred
  
IsNotPreferred
  
  
You have three states for Size of order:
  
total_cost &gt; 1000
  
total_cost &gt; 500
  
(whatever isn't covered by the previous states
  
  
2*3 = 6 input states
  
  
Output states is three
  
no transactions to all three transaction
  
  
2-E3 = 8 states. Due to the number of input states you will not be able to use all 8 states. Of course, some states will be invalid.
  
  
What seems to be exciting is that you can create a formal grammar from the set of rules you've implemented. 
  
  
The real trick that I really haven't seen, but I think that would be really cool is adding a compiling step (annotations?) to the business rules and not let you compile the program if you create a business rule that isn't part of the formal grammar.
  
  
The above would be a unit test on possible grammars?
  
  
Example:
  
  
when User.IsPreferred and Order.TotalCost &gt; 1000:
  
	SuggestUpgradeToPreferred 
  
	ApplyFreeShipping
  
  
Business Rule Compile Error: Customer is already preferred, no upgrade required.
  
  
  
  
  
  
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment11</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment11</guid><pubDate>Fri, 30 May 2008 02:33:16 GMT</pubDate></item><item><title>Ayende Rahien commented on The magic of boo - Flexible syntax</title><description>Joe,
  
I am not following about the combination of words.
  
  
About Size.Large, I would probably define a bunch of extension methods, so I could do things like:
  
Order.ApplicableForPrefferedShipping, or, actually:
  
Order.applicable_for_preferred_shipping.
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment10</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment10</guid><pubDate>Thu, 29 May 2008 04:03:24 GMT</pubDate></item><item><title>Joe Gutierrez commented on The magic of boo - Flexible syntax</title><description>DSL's are normally declaritive. A challenge I see in this DSL is this:
  
  
Order.total_cost &gt; 1000
  
  
This is more of a how than a what. If you add some properties to the the order class:
  
  
Size.Large, Size.Medium, Size.Small
  
  
I think it would be declarative this way. This would then equate to a sentence like this:
  
  
when User.is_preferred and Order.Size.Large:
  
    add_discount_precentage 5
  
    apply_free_shipping
  
  
Maybe change the action to read:
  
  
when User.is_preferred and Order.Size.Large:
  
    apply_preferred_discount
  
    apply_free_shipping
  
  
You could add another operation to your actions:
  
  
   apply_discount 2.5
  
  
As a side note, you have a total of 6 combinations of words. The total of original actions that can be created equals 8 different messages. What is up with that?
  
  
Another challenge is the Order sizes. If implemented as wriiten in the original rules you may run into some problems like:
  
  
when User.is_preferred and Order.Size.Large and not Order.Size.Medium:
  
  
  
This is some pretty exciting stuff! Keep it coming.
  
  
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment9</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment9</guid><pubDate>Thu, 29 May 2008 03:17:59 GMT</pubDate></item><item><title>Ayende Rahien commented on The magic of boo - Flexible syntax</title><description>Yes, all the actions would apply.
  
Idempotent? I don't think so.
  
  
It can be done fairly easily, but I haven't thought about this
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment8</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment8</guid><pubDate>Wed, 28 May 2008 07:42:57 GMT</pubDate></item><item><title>Joe Gutierrez commented on The magic of boo - Flexible syntax</title><description>What would happen if you instantiated, along with the the other business rules:
  
  
when User.is_preferred:
  
    apply_free_shipping 
  
  
What happens to the other business rules? It would seem that it is possible to have more than one business rule apply. 
  
  
If the first rule applies, then would this last rule apply. Are you're actions Idempotent?
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment7</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment7</guid><pubDate>Wed, 28 May 2008 04:20:23 GMT</pubDate></item><item><title>Ayende Rahien commented on The magic of boo - Flexible syntax</title><description>It is nice syntax, but I think it put too much information on one line.
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment6</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment6</guid><pubDate>Tue, 27 May 2008 18:14:15 GMT</pubDate></item><item><title>Chris Ortman commented on The magic of boo - Flexible syntax</title><description>If I were writing it in ruby I would probably do:
  
  
  
add_5_percent and apply_free_shipping if user.preferred? and order.total_cost &gt; 1000
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment5</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment5</guid><pubDate>Tue, 27 May 2008 18:07:12 GMT</pubDate></item><item><title>Ayende Rahien commented on The magic of boo - Flexible syntax</title><description>Eyad,
  
Personally, I never use underscores in my properties, so it is not a problem for me.
  
If you do have this issue, you would need to instruct the compiler in how to deal with this ambiguity
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment4</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment4</guid><pubDate>Tue, 27 May 2008 11:45:03 GMT</pubDate></item><item><title>Ayende Rahien commented on The magic of boo - Flexible syntax</title><description>Grega,
  
To answer your questions would take a book :-)
  
Luckily I am writing one of the topic.
  
You can get the information about it here:
  
http://www.manning.com/affiliate/idevaffiliate.php?id=854_111
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment3</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment3</guid><pubDate>Tue, 27 May 2008 11:44:03 GMT</pubDate></item><item><title>Eyad Salamin commented on The magic of boo - Flexible syntax</title><description>What if you needed to have underscores in one of your properties, won't the compiler crash?
  
I guess it should try to find the exact match of the reference, and if not found try to replace underscores and "Pascalize" it.
  
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment2</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment2</guid><pubDate>Tue, 27 May 2008 11:28:07 GMT</pubDate></item><item><title>grega g commented on The magic of boo - Flexible syntax</title><description>very nice
  
  
i have been reading your blog for some time and i am increasingly interested in boo &amp; dsl topic. But apart from seeing some dsl snippets, i would like an example how this fit into host application. Do you use compiler and compile it to memory? Maybe Interpreter? Or u make dll and reference it in host project. 
  
  
What about User? This has to be some variable that is supplied from host than consumed by script, changed and than returned. How does one do that?
  
  
Ty 
  
grega g
  
  
  
  
  
  
</description><link>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment1</link><guid>http://ayende.com/3336/the-magic-of-boo-flexible-syntax#comment1</guid><pubDate>Tue, 27 May 2008 11:21:46 GMT</pubDate></item></channel></rss>