4 ms·
Mediocre and bad code tends to multiply entities. On a small scale it's usually redundant global and local variables, or just plain stupid code like this:
by mojuba 12y ago
Mediocre and bad code tends to multiply entities. On a small scale it's usually redundant global and local variables, or just plain stupid code like this:
if (NULL == lpDataPointer)
{
/* Return FALSE */
return FALSE;
}
else
{
/* Return TRUE */
return TRUE;
}
Now give the same programmer an OOP language and see what happens. Even a bigger disaster masqueraded as an OOP system.
I know I kind of repeat the author's True Scotsman's metaphor, but my point is, you can't kill a return operator or, say, code comments just because the majority of code around us tends to misuse it. Unfortunately for the OOP paradigm it makes multiplying even bigger entities easier, and at the same time its learning curve invites lo-fi coding.
Who's to blame?
- MrDosu 12y agoWhats wrong about the above code? Does it not do what it means to do? Is your personal feeling for how this construct should be written syntactically any measure of intelligence?
- louthy 12y agoIt can be written: return (NULL != lpDataPointer)
- MrDosu 12y agoI know, it can also be written in many other ways. What decides which one is more correct if they are all semantically equivalent? Is it less characters? Is it using exactly as many 'e's as 'a's? Is it the unnecessary braces?
- mojuba 12y agoThere is probably no "correct" way of writing this, but there are ways of making your next code maintainer's life easier (which might be you in a few months from now). One line is easier to read and understand than 10, especially if that one line is just "return p".
- MrDosu 12y agoPersonally most of the time id rather have 10: main(int c,charv){return!m(v[1],v[2]);}m(chars,chart){returnt-42?s?63==t|s==t&&m(s+1,t+1):!t:m(s,t+1)||*s&&m(s+1,t);}
- mojuba 12y agoBut I meant return p, not some gibberish that obviously should be formatted better. It's just that for some developers "formatting better" doesn't translate to "make it shorter and sweeter".
- MrDosu 12y agoHow dare you call this beautiful, correct and award winning glob matcher gibberish shakes fist
- mojuba 12y agoOr, taken to the extreme: return p;
- louthy 12y agoDepends on the language. Clearly 'lpDataPointer' suggests C or C++, but if it was C# or Java then 'return p;' would only compile if 'p' was of boolean type. </pedant>