Ok so I have a query. It returns a model with a bunch of bool flags. Based on these flags I can run a bunch of if checks returning early when we are done with an action or falling through if no checks match.
var queryResult = complexQuery
If (queryResult.IsBroke)
{
letPeopleKnow();
return;
}
If(queryResult.RetryNeeded)
{
doARetry();
return;
}
...... and more scenarios some of which are then nested
I enapsulate setting the state based on myriad rules on the model returned to hide this from calling class.
Ive TDDd and therefore I have no more or no less than I need with various refactorings for readability etc (not shown here) but I am loate the refactor to a pattern (perhaps chain of responsobility or strategy) just for the sake of it.
I did have an idea of modelling a specific return type for each scenario and/ encapsulating action in this or providing ability to attach an action. I am a liitle rusty I guess at breaking stuff out coherently.
Aucun commentaire:
Enregistrer un commentaire