This project is read-only.

Supporting multiple dialects

Sep 4, 2008 at 9:31 PM
I've been looking into how we can deal with multiple dialects of the StoryQ DSL. We can use different extension method namespaces to provide these. We'll have to rename all the fragments to give them dialect-independent meaning. I think the following rename makes things cleaner too:

AsA => Role
IWant => Ability
SoThat => Benefit

Given => Condition
When => Operation
Then => Outcome

that would support the following "importable" dialect:

namespace StoryQ.Dialect.AsAIWantSoThat
{
    public static class Extensions
    {
        public static Role AsA(this Story story, Narrative narrative)
        {
            return new Role {Narrative = narrative, Parent = story, Prefix = "as a"};
        }

        public static Ability IWant(this Role role, Narrative narrative)
        {
            return new Ability { Narrative = narrative, Parent = role.Parent, Prefix = "i want" };
        }

        public static Story SoThat(this Ability ability, Narrative narrative)
        {
            Benefit benefit = new Benefit {Narrative = narrative, Parent = ability.Parent, Prefix = "so that"};

            return benefit.Parent;
        }

        public static Scenario WithScenario(this Story story, Narrative narrative)
        {
            return new Scenario { Narrative = narrative, Parent = story, Prefix = "with scenario" };
        }
    }
}

Sep 4, 2008 at 10:16 PM
And you can switch to this by importing another dialect. You could even write your own without having to touch the storyQ source
namespace StoryQ.Dialect.InOrderToAsAIWant
{
    public static class Extensions
    {

        public static Benefit InOrderTo(this Story story, Narrative narrative)
        {
            return new Benefit {Narrative = narrative, Parent = story, Prefix = "in order to"};
        }

        public static Role AsA(this Benefit benefit, Narrative narrative)
        {
            return new Role {Narrative = narrative, Parent = benefit.Parent, Prefix = "as a"};
        }

        public static Story IWant(this Role role, Narrative narrative)
        {
            Ability ability = new Ability { Narrative = narrative, Parent = role.Parent, Prefix = "i want" };
            return ability.Parent;
        }

        public static Scenario WithScenario(this Story story, Narrative narrative)
        {
            return new Scenario { Narrative = narrative, Parent = story, Prefix = "with scenario" };
        }
    }
}
Sep 5, 2008 at 5:24 PM
That should be nice to allow for the different dialects. I also like that you can ovveride the prefix too.

Dialect One:

As a [X]
I want [Y]
so that [Z]

Dialect Two:

Elizabeth Keogh is suggesting that business value needs to come first. This narrative now reads:

In order to <achieve some value>
As a <role>
I want <some feature>