More ideas on syntax for builders

1 view
Skip to first unread message

Eric Lefevre-Ardant

unread,
Dec 1, 2010, 12:05:19 PM12/1/10
to narrati...@googlegroups.com
I've started to introduce 'with()' and 'and()' keywords in the builders I use for actions. They don't do anything technically useful (just 'return this'), but are handy for readability.

Before:
    When.the(quant).attempts_to(view_the_bar_chart().for_instrument(CAC_40).and_bar_type(Hourly).and_start_date(utc(2010, 01, 05)).and_end_date(utc(2010, 01, 05)));

Now:
    When.the(quant).attempts_to(view_the_bar_chart().with().instrument(CAC_40).bar_type(Hourly).start_date(utc(2010, 01, 05)).and().end_date(utc(2010, 01, 05)));

Notice that I do not need to make 'for_instrument()' the first call anymore.

Eric

Douglas Squirrel

unread,
Dec 1, 2010, 12:59:10 PM12/1/10
to narrati...@googlegroups.com

I think we've considered these before - what do others think? Happy to look at a pull request if and when ready.

Samir Talwar

unread,
Dec 1, 2010, 1:02:58 PM12/1/10
to narrati...@googlegroups.com
On the list for the next version is a BaseActor abstract class that implements the boring parts of the interfaces in a way that will be useful for most users of Narrative. Perhaps we should consider a BaseAction with useful methods such as these. I'm thinking of introducing them in my matchers too.

— Samir.
Reply all
Reply to author
Forward
0 new messages