-
Notifications
You must be signed in to change notification settings - Fork 90
Keeping it clean
Josh Hiles edited this page Dec 22, 2023
·
1 revision
Sometimes you don't want to store the full value for later analysis. For example, an experiment may return IUser instances, but when researching a mismatch, all you care about is the logins. You can define how to clean these values in an experiment:
public IUser GetUserByEmail(string emailAddress)
{
return Scientist.Science<IUser, string>("get-user-by-email", experiment =>
{
experiment.Use(() => OldApi.FindUserByEmail(emailAddress));
experiment.Try(() => NewApi.GetUserByEmail(emailAddress));
experiment.Clean(user => user.Login);
});
}And this cleaned value is available in the final published result:
public class MyResultPublisher : IResultPublisher
{
public Task Publish<T, TClean>(Result<T, TClean> result)
{
// result.Control.Value = <IUser object>
IUser user = (IUser)result.Control.Value;
Console.WriteLine($"Login from raw object: {user.Login}");
// result.Control.CleanedValue = "user name"
Console.WriteLine($"Login from cleaned object: {result.Control.CleanedValue}");
return Task.FromResult(0);
}
}- Publishing results
- Controlling comparison
- Adding context
- Expensive setup
- Keeping it clean
- Ignoring mismatches
- Enabling or disabling experiments
- Ramping up experiments
- Running candidates in parallel (asynchronous)
- Testing
- Handling errors
- Designing an experiment
- Finishing an experiment
Sometimes scientists just gotta do weird stuff. We understand.