samedi 25 juillet 2015

Name for phenomenom: if if else

Last week I heared about a phenomenom about if-Statements. It had a specific name, but I can't remember it.

The Problem is about an if-if-else construction, for example:

if( a!=null )
if( a.isTrue() )
    a.performAction(); 
else
    a.healCondition(); // second chance to do something

So the problem comes from missing brackets. It wouldn't be a problem if I use brackets for the outer if. Without brackets it is not always clear to which "if" the "else" belongs to.

But I don't want to have a solution for that problem. I would be happy to know how this pattern is called.

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire