samedi 26 mars 2016

Convert if else to Pattern

I am using Laravel to build a system, this system is very complex and it contains too many if else, I want to change and clean up the code to be easier to maintain.

I have something like this

if(A)
{
    call_a();
}
else
{
    if(B)
    {
        call_a();
    }
    else
    {
        if()
        {
            call_b();
        }
        else
        {
            if(C)
            {
                call_a();
            }
            else
            {
                call_b();
            }
        }
    }
}

of course its more and more complex.

Any help ? THanks

Aucun commentaire:

Enregistrer un commentaire