Once more... Invert if statement to reduce nesting

ok...I know this is probably a well beaten dead horse, but..

public function(stringorobject param)
{
    if(somethingthatisrequiredforfunctionality == null)
    {
         somethingthatisrequiredforfunctionality = new somethingthatisrequiredforfunctionality () { member1="initialvalue", member2="anotherinitialvalue" };
         //or
        somethingthatisrequiredforfunctionality.Initialize("startupobject_or_string");
    }

    // go ahead an use somethingthatisrequiredforfunctionality
   somethingthatisrequiredforfunctionality.prepareobject(param);
   return callotherfunction(somethingthatisrequiredforfunctionality);
}

Why is resharper saying anything about reducing nesting - how the heck else do you write this? lol

Help...

R

1 comment
Comment actions Permalink

Hi Robert,

Couldy ou please provide a full code sample/solution, which will demonstrate this behavior? I cannot get this suggestion to invert if statement on this piece of code, unfortunately.

Thank you in advance!

0

Please sign in to leave a comment.