Welcome to tankete.com Sign in | Join | Help

José Lema

Inside the Community Server development team

Shared Posts


Badges



  • www.flickr.com
    This is a Flickr badge showing public photos from tankete. Make your own badge here.
Merlin: Defining the Rule

This is part four of a series on Merlin. I recommend you read from the beginning.

Answering the "how" would come later. For now I decided that my focus should be on the "what". Again, pulling from the concepts of Outlook's Rules Wizard, I determined that a rule is run in some context. Keeping it simple (and singular...for now) I defined a rule as an action that is executed whenever a condition is evaluated to true. (You'll notice I excluded the concept of an exception at this time). Turning my thoughts into code produced something simple, like the following:

public class Rule
{
    public void Run(Context context)
    {
        if (condition.Evaluate(context))
            action.Execute(context);
    }
}

Satisfied with my definitions and some pseudo-code to support them, I jumped back to problem at hand. What form should a rule take in order to keep it as flexible as possible. Following a similar pattern used throughout CommunityServer, I simply decided to store a rule as xml with pointers to the bits of code it required. My initial stab at a rule looked a bit like this:

<rule name="xxx">
    <condition type="yyy" />
    <action type="zzz" />
</rule>

It was at this time that I realized that to the degree that Merlin stayed generic, I would be free to leverage rules from any part of CS or any other application, for that matter.

I now had an idea brewing for how to tie this rule definition into CSModules, but I needed to run a few quick tests first...   (continued)

Posted: Thursday, September 21, 2006 2:30 PM by Jose
Filed under: ,

Comments

Dan Hounshell said:

Tell us about the tests! Tell us about the tests! Tell us about the tests!

# September 21, 2006 9:46 PM

Community Server Daily News said:

news of the day a grab bag for what's happening in Community Server Telligent's Dan Hounshell describes

# September 25, 2006 4:28 PM

Daily News Faq List said:

Telligent's Dan Hounshell describes Jose Lema's recent writing as "A Developing Cliff-hanger." In last

# November 22, 2006 11:15 AM

Community Server Bits said:

Telligent's Dan Hounshell describes Jose Lema's recent writing as "A Developing Cliff-hanger." In last

# March 12, 2007 11:21 AM
New Comments to this post are disabled