jeudi 22 juin 2017

Same computational flow, but different functionalities

Recently I wrote a small piece of code for my project need and the code works fine...

Below code is a generalized version....

if (Utils.nullOrEmpty(string1))
        {
            Config config = getConfig();

            if (config != null)
            {
                doX();
            }
        }
        else
        {
            doY();
        }

        if (Utils.nullOrEmpty(string2))
        {
            Config config = getConfig();

            if (config != null)
            {
                doA();
            }
        }
        else
        {
            doB();
        }

I am not convinced the way it is written and I feel there is a scope for improvement to make it better........

Please give me some suggestions to make it better... Is there a scope to use lambdas ??.........

Aucun commentaire:

Enregistrer un commentaire