davezych / shience

A .NET port(ish) of Github's Scientist library. (https://github.com/github/scientist)
MIT License
9 stars 1 forks source link

Experiment should get additional extension methods #21

Closed MovGP0 closed 8 years ago

MovGP0 commented 8 years ago

There should be extension methods to make use of the ExperimentResult object more fluent:

science
    .Execute()
    .OnSuccess((controlResult, candidateResult, context) => ...)
    .OnError((controlResult, candidateResult, context) => ...)
davezych commented 8 years ago

Execute returns TResult, not ExperimentResult<TResult>. The reason for this is that the experiment results are really only useful in publishing, and the application flow only needs the result of the control function.

I'm not sure I see a need to have it return an experiment result.

MovGP0 commented 8 years ago

Sorry. I mixed up the order. What I meant was essentially that instead of:

Shience.New<bool>("name")
    .PublishTo(result => HandleSuccessOrError(result))
    .Execute().

we could do something like:

Shience.New<bool>("name")
    .PublishTo(result => HandleSuccessOrError(result))
    .PublishSuccessTo(result => HandleSuccess(...))
    .PublishErrorTo(result => HandleError(...))
    .Execute()

The advantage is that this style leads to a better separation of concerns in the user code.

MovGP0 commented 8 years ago

the additional methods are implemented, but they need testing and documentation.