5 ms·
Eeeek. That code would've been terrible practice in 2000 when I first started writing Perl :( The Mysql module was deprecated in favour of the unified DBI inte
by mst 13y ago
Eeeek. That code would've been terrible practice in 2000 when I first started writing Perl :(
The Mysql module was deprecated in favour of the unified DBI interface, cgi-lib.pl was a perl4 library that was replaced by a module called CGI (shipped with perl5 itself from 5.4+).
Calling functions with & is a perl4-ism and almost always the wrong thing to do in perl5, and C-style for is silly in most cases in Perl - for example; the loops in there would likely be better redone as foreach loops, or possibly just a grep.
And, of course, YAY not using placeholders in the SQL.
sigh
- neilmiddleton 13y agoJust goes to show how much code quality contributes to a successful product.
- X4 13y agoFully agree with you on that. Perfectionism or shooting the bird with one bullet only is not what made Facebook a billion dollar company. a) Serve b) Improve quality c) goto a)
- matthewmacleod 13y agoNo it doesn't - it only demonstrates that products can succeed despite poor code quality.
- ninkendo 13y agoI think that's what he meant... it shows how much code quality contributes to success: not much at all.
- matthewmacleod 13y agoAnd that's exactly what I didn't mean. It's a sample of one, and offers no information whatsoever about how much code quality can contribute to success, except that rubbish code doesn't totally preclude the hope that a product might be successful. Let's say things had turned out a little differently, and someone had used one of those SQL injections to irreversibly erase all of early Facebook's data. We'd probably never have heard of it again. Code quality is a good thing - like scalability, and security. Ultimately, you might succeed without it. But it'll probably be easier if you do.
- nikatwork 13y agomy fave snippet is from line 206: } } } } } } To be fair I've seen that pattern in just about every codebase I've touched, sadly.
- ra88it 13y agoWhat do you mean? Is that considered too deep nesting? (I'm not trying to be sarcastic.)
- carbocation 13y agoIt means nikatwork is not going to like the aesthetics of lisp.
- nikatwork 13y agoI like Lisp. My problem with this code is not aesthetics. This logic is too deeply nested, by the time you hit the last conditional there is way too much going on[1]. Perl makes it especially nice to flatten logic due to RHS conditionals, eg "x++ if y;". Here is my two minute flattening job[2], it prob has syntactic errors but you get the gist. [1] http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_... [2] http://pastebin.com/4TDVftpJ http://pastebin.com/4TDVftpJ
- meowface 13y agoLots of SQL injection in there, too.