Mistři v programování na #hovnokod

C# #1014

The Try antipattern

public static TResult Try<T, TResult>(this T value, Func<T, TResult> result)
{
   return value != null ? result(value) : default(TResult);
}

...

return value.Try(i => new request
    (
     new configuration
     {
      code = i.Item2
     },
     i.Item1.Try(i2 => i2.Data.Try(i3 => i3.ToDto())),
     i.Item1.Try(i2 => i2.Data2.Try(i3 => i3.ToDto())),
     i.Item1.Try(i2 => i2.Data3.Try(i3 => i3.ToDto())),     
     i.Item1.Try(i2 => i2.Data4.Try(i3 => i3.ToDto()))
    ));

Anonymous,