|
The names suggest that it's a public method which calls a method on a private member, so unless you're horribly opposed to encapsulation there's nothing wrong with the function existing.
|
# ? Nov 14, 2009 19:45 |
|
|
# ? Apr 28, 2024 00:09 |
|
tef posted:yes newline Man I'm dumb. I'll file that away. It'll come in useful one day.
|
# ? Nov 15, 2009 00:43 |
|
Hey guys, we're on reddit: http://www.reddit.com/r/programming/comments/a4f97/coding_horrors_code_that_makes_you_laugh_or_cry/
|
# ? Nov 15, 2009 03:45 |
|
You know it's funny, a good number of people reading this thread and that reddit thread would probably be guilty of a number of things in this thread. Programming should be more like music, where you compete against yourself rather than bash those who suck, but then nothing would get done.
|
# ? Nov 15, 2009 03:58 |
|
ton1c posted:You know it's funny, a good number of people reading this thread and that reddit thread would probably be guilty of a number of things in this thread. Programming should be more like music, where you compete against yourself rather than bash those who suck, but then nothing would get done. I don't understand. There are musical pieces that everyone, even those who don't know a thing about musical theory, can agree are loving terrible.
|
# ? Nov 15, 2009 04:54 |
|
ton1c posted:You know it's funny, a good number of people reading this thread and that reddit thread would probably be guilty of a number of things in this thread. Programming should be more like music, where you compete against yourself rather than bash those who suck, but then nothing would get done. And nobody should ever listen to each others music, we'll all just whittle our own instruments and play holed up in our rooms and never speak of it again. Most importantly, we'll never critique one another's music. This will guarantee all but one of us are stuck at the beginner level, and we'll all be happy.
|
# ? Nov 15, 2009 07:58 |
|
ton1c posted:You know it's funny, a good number of people reading this thread and that reddit thread would probably be guilty of a number of things in this thread. I'm pretty sure some of the posts have been people outing some of the horrible code they've written. It's rather cathartic. quote:Programming should be more like music, where you compete against yourself rather than bash those who suck, but then nothing would get done. Hackers and Composers eh? I'm not sure you can attribute the desire to code to a competitive element alone, nor any progress to such a poor motive.
|
# ? Nov 15, 2009 16:35 |
|
Factor Mystic posted:It's indicative of 1:1 mental modelling to code, and shows that to him the code only makes sense if it explicit returns "true" somewhere and "false" somewhere else. There's no jump to the higher order of thinking where the return value of the call can be returned, or once you've achieved that, possibly scrapping the helper function altogether because you realize the inner call does everything you need. Another possible explanation is that at some point, the code actually did more work itself. Later, the manual code was replaced with a call to the other method, and the rest was left alone.
|
# ? Nov 16, 2009 00:11 |
|
tef posted:I'm pretty sure some of the posts have been people outing some of the horrible code they've written. It's rather cathartic. Hi, my name is poopgiggle and I have written horrible code. (*Hi poopgiggle!*) When writing quick text-munging Perl scripts for work I have been known to wrap error-prone code in "eval" blocks rather than fixing boundary conditions in order to get something to work quickly. I have left code entirely undocumented except for one comment at the top, reading "documentation left as an exercise to the reader." I have authored regular expressions which were about 4" wide on the screen. There's probably more.
|
# ? Nov 16, 2009 05:13 |
|
poopgiggle posted:I have authored regular expressions which were about 4" wide on the screen. http://github.com/brosner/everyblock_code/blob/master/ebdata/ebdata/nlp/addresses.py I hope this makes you feel tiny.
|
# ? Nov 16, 2009 05:40 |
|
king_kilr posted:http://github.com/brosner/everyblock_code/blob/master/ebdata/ebdata/nlp/addresses.py While we're at it: quote:Mail::RFC822::Address: regexp-based address validation
|
# ? Nov 16, 2009 05:47 |
|
Janin posted:Mail-RFC822-Address If you break it down part by part and combine the regexes, it's not so bad. Datamapper does a good job of that, see: http://github.com/datamapper/dm-more/blob/master/dm-validations/lib/dm-validations/formats/email.rb
|
# ? Nov 16, 2009 06:17 |
|
Janin posted:While we're at it: As I recall this doesn't actually perfectly parse emails, RFC822 allows infintely nested comments, this just allows REALLY nested comments. regex aren't powerful enough to parse 822.
|
# ? Nov 16, 2009 06:48 |
|
My most infamous moment of retarded coding was when I was trying to figure out an algorithm for automatically placing wall pieces around a set of rooms in a game. There were a total of 256 different combinations of wall pieces that were needed to cover all possibilities. I thought for ages over the algorithm, but just couldn't make any headway, it really was just too tricky. So I gave up, and started writing a switch statement to manually handle all 256 cases. I knew it was terrible, but I just couldn't figure out how to do it algorithmically. I got to about case 80 before realising that if I changed my data structures a bit, I could write the algorithm in about 5 lines.
|
# ? Nov 16, 2009 09:59 |
|
poopgiggle posted:I have authored regular expressions which were about 4" wide on the screen. code:
|
# ? Nov 16, 2009 11:14 |
|
Zombywuf posted:I once wrote one 4 screens wide: As someone else who was paid to write a series of regular expressions to translate html into well formed xml I would like to say
|
# ? Nov 16, 2009 12:02 |
|
Janin posted:While we're at it: I think my favorite parts are lookaheads nested inside lookaheads inside other lookaheads.
|
# ? Nov 16, 2009 20:24 |
|
nbv4 posted:I think someone doesn't know what "release candidate" means... The inflation of software release milestones: http://technet.microsoft.com/en-us/magazine/2008.03.windowsconfidential.aspx?pr=blog
|
# ? Nov 16, 2009 20:28 |
|
yaoi prophet posted:I think my favorite parts are lookaheads nested inside lookaheads inside other lookaheads. If there's ever been a 'Yo Dawg' of Regexes, it would be this one. This is from an assignment I had to write for my compilers class. I had reached a point of frustration with JavaCC and submitted this chunk of code amongst my actual answers: code:
|
# ? Nov 16, 2009 20:30 |
|
Where I work, there's a bunch of php legacy code that's just so fuckin' bad. It's worse than the worst stuff I ever wrote while in school learning the basics of programming. It's as if the programmer went out of his way to break the DRY rule at every possible turn, while having includes that made no sense and did no favors in terms of code readability. I'm going to be rewriting some of it before the end of the year, and I can't wait, because maintenance of the old crap is horrible and makes me want to hurt people. I'll post some true eyesores a bit later.
|
# ? Nov 16, 2009 22:07 |
|
code:
|
# ? Nov 16, 2009 22:57 |
|
Vanadium posted:unix programming is the best programming I could post some shell scripts that would make your eyes bleed. No one I work with understands sourcing or how to pass arguments so there's a lot of duplicated information which leads to lots of inconsistencies as well as directories filled with things like: code:
|
# ? Nov 17, 2009 21:25 |
|
Does this:php:<? if(is_numeric($extid)) $sql .= "us_extid=$extid"; else $sql .= "us_extid='".$extid."'"; ?> *that's a 6-digit number with a leading zero, fyi
|
# ? Nov 17, 2009 21:55 |
|
Munkeymon posted:Does this: Can't you typer your variable before you put stuff into it? And 1 quick google found this. quote:Comparing a non-numeric string to the integer 0 by using == will return true, since the string will be casted to integer - which will be zero. If your string starts with a number, it will be castet to an integer with the number as value.
|
# ? Nov 17, 2009 23:40 |
|
Sprawl posted:Can't you typer your variable before you put stuff into it? Strict typing would require about a week of work for rewriting and testing while this had to be done today. Also, I don't see how the behavior of == makes any difference to is_numeric, which quite clearly changed its behavior when acting on the same data as I tapped F5 a few times earlier today.
|
# ? Nov 18, 2009 00:12 |
|
Defined in a base classcode:
code:
|
# ? Nov 19, 2009 14:08 |
|
Not really code but my coworker told me that some of our customers want their automated reports emailed to multiple recipients and that he was just going to add some more email field columns to the customer table. I looked him square in the eye and said "you know drat well the right thing to do is create a new table linked to the customer table". He sighed and said "yeah, was trying to avoid that". He's actually a very good database guy, just lazy sometimes.
|
# ? Nov 19, 2009 19:55 |
|
golgo13sf posted:Not really code but my coworker told me that some of our customers want their automated reports emailed to multiple recipients and that he was just going to add some more email field columns to the customer table. Make a Text blob and use , to separate them since that's how you would multi-mail it anyways.
|
# ? Nov 19, 2009 19:58 |
|
golgo13sf posted:He's actually a very good database guy, just lazy sometimes. Who isn't? That's what you have code review for.
|
# ? Nov 19, 2009 20:15 |
|
Sprawl posted:Make a Text blob and use , to separate them since that's how you would multi-mail it anyways. Not forwards compatible with Wave.
|
# ? Nov 20, 2009 16:20 |
|
I just spent an hour or so helping a friend with tracking down a bug after he migrated some PHP scripts to a new server. The culprit? Let me just quote http://www.php.net/manual/en/function.gd-info.php: quote:Previous to PHP 5.3.0, the JPEG Support attribute was named JPG Support. Stay classy, PHP team.
|
# ? Nov 20, 2009 20:00 |
|
Out of curiosity, Broken Knees Club, did you ever find out what makes GCC die without this define in your codebase?Broken Knees Club posted:So while messing around in an old codebase I stumbled on this:
|
# ? Nov 20, 2009 21:31 |
|
Ledneh posted:Out of curiosity, Broken Knees Club, did you ever find out what makes GCC die without this define in your codebase? That's so weird that I'm not sure normal logic can be applied to it, but wouldn't it make sense to diff the preprocessor output with and without that #define statement to see what changes? If you can't find the flag itself, I doubt that would help, but it seems like it could be worth a try.
|
# ? Nov 21, 2009 03:46 |
|
ultra-inquisitor posted:My most infamous moment of retarded coding was when I was trying to figure out an algorithm for automatically placing wall pieces around a set of rooms in a game. There were a total of 256 different combinations of wall pieces that were needed to cover all possibilities. I was writing minimap code a while back for a randomly generated level. The level fragments consisted of a bunch of tiles, any of which could be rotated 90 degrees to slot into the game itself. To save on memory I'd done a bunch of heuristics to combine "similar" tiles in the minimap-fragment texture, so a 2x2 round room would end up represented by a single 90-degree arc which was then pointed to four times, with optional rotation flags. Wait, did I say "rotation"? My mistake. For the sake of rendering speed it was actually represented as a series of three flips, horizontal/vertical/diagonal. Some segments of the codebase did these in a different order, and none of us could ever remember which order we were "supposed" to be using. So: take HVD flips, then try to algorithmically generate a 90 degree clockwise rotation. Solution: build a tiny interface to allow me to just jam rotations into the game engine and see what it looked like, then sit in front of the console for three minutes with a scrap of paper, bruteforcing the rotation matrix by hand. End result: code:
|
# ? Nov 21, 2009 05:40 |
|
Not a horor, a response to a horror from a co-workers blog that I found amusing:quote:Digression: Adverts are the bane of my life. If you want to include banner ads on your site, an ad network will typically give you a piece of JavaScript to insert on your page wherever you want the ad to appear. This JavaScript will typically be some of the most hideously tortuous code you have ever seen. It will reveal a positively Lovecraftian chain of document.write() calls, eval() statements, and nonsensical browser hacks that eventually result in a 2MB Flash file being pulled over a 28.8kbps network connection from somewhere in Kazakhstan. Advert code is the closest thing modern science has to the Berryman Logical Imaging Technique. I hear that the CIA used to teach terrorist suspects JavaScript just so they could expose them to advert code, and break their wills.
|
# ? Nov 23, 2009 10:57 |
|
New release of my favourite software! Required changes to existing files: -Insert this code (in multiple places): php:<? $text = str_replace('à','//acute//',$text); $text = preg_replace('{[ \s]+}', ' ', $text); $text = str_replace('//acute//','à',$text); ?> -Edit existing code, to replace with this: php:<? $str = preg_replace("/(<br>|<BR>|<br \/>|<BR \/>|&lt;br&gt;|&lt;BR&gt;|&lt;br \/&gt;|&lt;BR \/&gt;)/"," //br// ",$str)." "; ?>
|
# ? Nov 24, 2009 22:19 |
|
Surge Strip posted:So many things wrong. He even got an error that Uppercase was already defined, and so he misspelled it. We got a lot of this. I'm a tester for a company making truss design software. A few years ago they outsourced the creation of an automated testing suite, along with some of their actual programming hours. The inevitable result was a 50 person team of Indian programmers triple spacing their code, misspelling common words as variables and a lot of scoped variable, function, object, class, and method re-declarations. It's not difficult to find examples of a window declaration in our testing suite's coding language, mirrored by another declaration with a single letter missing or some other retardation:
They also completely ignored any error/exception trapping, even though there is a convenient do/except (essentially a try/catch) functionality built into the testing suite language. Instead of trapping exceptions they used a universal error code system consisting of an integer variable "iStatus" that could be 0, 1, 2, or 3. These error codes were made into constants called AEP_ERROR, AEP_FAILURE, AEP_SUCCESS, and something else I can't really bring myself to remember now. Every single function or method was typed int and would return one of the constants depending on the success of the function. So they would call a function, assign its return value to iStatus and immediately test the value of iStatus after the function call. code:
Here's one of their functions: code:
And that's after I grew resigned to spending 5 minutes of cleanup each time I crack open a testcase to troubleshoot. We've practically halved the lines of code in the last year, just by removing duplicate functions and the extra spaces. We haven't even been able to estimate the manhours to strip out the iStatus error codes and replace it with real raises and exception objects.
|
# ? Nov 24, 2009 22:37 |
|
Every time I see a regex horror I have to remind myself that few people know about the /x flag for Regexes. If you're doing anything even mildly complicated with regexes, you're perpetuating a horror unless you use the /x flag and spread it out across a few lines, possibly with some comments in the particularly "clever" sections. Zombywuf's horror a few posts back could have been: code:
code:
jandrese fucked around with this message at 19:43 on Nov 26, 2009 |
# ? Nov 25, 2009 23:02 |
|
jandrese posted:Zombywuf's horror a few posts back could have been: Number one is that the application was not written in vb6.
|
# ? Nov 26, 2009 19:11 |
|
|
# ? Apr 28, 2024 00:09 |
|
From the helpful comments department:code:
code:
pokeyman fucked around with this message at 00:25 on Nov 27, 2009 |
# ? Nov 26, 2009 22:32 |