Pergunta

I've often come across bugs that have been caused by using the ELSE construct. A prime example is something along the lines of:

If (passwordCheck() == false){
    displayMessage();
}else{
    letThemIn();
}

To me this screams security problem. I know that passwordCheck is likely to be a boolean, but I wouldn't place my applications security on it. What would happen if its a string, int etc?

I usually try to avoid using ELSE, and instead opt for two completely separate IF statements to test for what I expect. Anything else then either gets ignored OR is specifically handled.

Surely this is a better way to prevent bugs / security issues entering your app.

How do you guys do it?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
scroll top