Despite best efforts, we will all at some point or another come across “stars-align” logic. It usually sits at the intersection of business logic and technical requirements (a smell of it’s own) and looks a little something like this:
if (model.SomeProperty.HasValue
&& model.OtherProperty > config.MinimumPermitted
&& user.HasPermission
&& (!model.RequiresFeatureX || featureX.IsEnabled))
{
// Preferred Behaviour
}
else
{
// Plan B
}
We’re already in a bad place here and the ideal solution is to refactor. We should never have reached this point, but code rot is a death by a thousand cuts and there’s only so much technical debt that can be factored into your workload.
[Read More]