Redundant code constructs

Posted by Diomidis Spinellis on Stack Overflow See other posts from Stack Overflow or by Diomidis Spinellis
Published on 2008-09-26T12:45:13Z Indexed on 2010/05/12 7:24 UTC
Read the original article Hit count: 200

Filed under:
|

The most egregiously redundant code construct I often see involves using the code sequence

if (condition)
    return true;
else
    return false;

instead of simply writing

return (condition);

I've seen this beginner error in all sorts of languages: from Pascal and C to PHP and Java. What other such constructs would you flag in a code review?

© Stack Overflow or respective owner

Related posts about beginner

Related posts about coding-style