|
Trying to untangle a customer's project with a view to taking it on, I just came across this delightful little nugget:code:
p.s. the try block preceding this contained 230 lines of code. chippy fucked around with this message at 15:46 on Aug 5, 2013 |
# ? Aug 5, 2013 15:43 |
|
|
# ? Jun 7, 2024 18:07 |
|
I love working on code some (probably 1st/2nd semester) CS students wrote:php:<? function doTheThing($prim_id, $second_id = null){ if($prim_id != null){ $data = getDataViaPrimId($prim_id); // 50LoC doing stuff with $data return $data; }else{ $data = getDataViaSecId($second_id); // exactly the same 50LoC doing stuff with $data return $data; } } ?>
|
# ? Aug 5, 2013 16:07 |
|
ReelBigLizard posted:That is pretty much the entire document, which was a .docx. You can google that string and get a result.
|
# ? Aug 5, 2013 17:07 |
|
chippy posted:Trying to untangle a customer's project with a view to taking it on, I just came across this delightful little nugget: So the horror is that they named the Exception variable "exp" right
|
# ? Aug 5, 2013 18:43 |
|
Amarkov posted:So the horror is that they named the Exception variable "exp" right
|
# ? Aug 5, 2013 19:04 |
|
Pilsner posted:Heh, I thought of that too. Other annoying variations are "exc". Or naming it when it's not even used is bad. Can you catch exceptions anonymously in Java? I was under the impression that you can't. (But then again, lots of people are under the impression that you can't access private fields in other classes...)
|
# ? Aug 5, 2013 19:19 |
|
Pilsner posted:Heh, I thought of that too. Other annoying variations are "exc". Or naming it when it's not even used is bad. All of my exception variable names are either "e", "ex", or an acronym for the exception like NullReferenceException becomes "nre". How else are you supposed to do it?
|
# ? Aug 5, 2013 19:25 |
|
Amarkov posted:Can you catch exceptions anonymously in Java? I was under the impression that you can't. (But then again, lots of people are under the impression that you can't access private fields in other classes...) Factor Mystic posted:All of my exception variable names are either "e", "ex", or an acronym for the exception like NullReferenceException becomes "nre". How else are you supposed to do it?
|
# ? Aug 5, 2013 19:41 |
|
Pilsner posted:Oh, I don't know, but you can in .NET. Well isn't dot NET fancy fake e: code:
|
# ? Aug 6, 2013 00:00 |
|
I know a lot of memes but I'm still not catching that one. Explain it for us?
|
# ? Aug 6, 2013 00:45 |
|
xtal posted:I know a lot of memes but I'm still not catching that one. Explain it for us? That's not some acronym at the end. That's "pls", as in "please" finish running, because the method doesn't guarantee that running actually will be finished at the end.
|
# ? Aug 6, 2013 02:05 |
|
Amarkov posted:That's not some acronym at the end. That's "pls", as in "please" finish running, because the method doesn't guarantee that running actually will be finished at the end. That's actually what I thought, but I didn't get the meme connection. "pls" is a pretty ancient and common abbreviation. Probably was used in smoke signals at a point.
|
# ? Aug 6, 2013 02:32 |
|
xtal posted:That's actually what I thought, but I didn't get the meme connection. "pls" is a pretty ancient and common abbreviation. Probably was used in smoke signals at a point. Yeah, that's not a meme. At least not in the sense of "goddamn 4channers get off my lawn for inventing this poo poo".
|
# ? Aug 6, 2013 03:11 |
|
Thermopyle posted:Yeah, that's not a meme. At least not in the sense of "goddamn 4channers get off my lawn for inventing this poo poo". Huh, really? I'd never heard it except from 4chan and redditors trying too hard to be 4chan.
|
# ? Aug 6, 2013 07:05 |
Amarkov posted:Huh, really? I'd never heard it except from 4chan and redditors trying too hard to be 4chan. I was writing "plz" and "thx" and poo poo like that in QuakeWorld Team Fortress games 15 years ago. Sorry.
|
|
# ? Aug 6, 2013 07:44 |
|
nielsm posted:I was writing "plz" and "thx" and poo poo like that in QuakeWorld Team Fortress games 15 years ago. Sorry. Rock, no opengl plz!!!!!
|
# ? Aug 6, 2013 17:10 |
|
Somehow, the following code pattern was so great that my entire team implemented it into their home-rolled framework. Heavy anonymization on my part that might not make the intent of the original code clear.PHP code:
PHP code:
It goes deeper, it keeps going and going and just when you think you're done, it goes some more. I was going to trace the whole thing through, but as I anonymized HotDogMeal I slowly became more and more depressed. I hope this serves as some framing device for the "ingenuity" I have to deal with daily.
|
# ? Aug 6, 2013 18:26 |
|
I love how PHP's only data structure is basically the ideal one to use for passing arbitrary arguments to a function, but someone said "haha gently caress that!"
|
# ? Aug 6, 2013 18:50 |
|
EntranceJew posted:Somehow, the following code pattern was so great that my entire team implemented it into their home-rolled framework. Heavy anonymization on my part that might not make the intent of the original code clear. My co-worker wrote basically the same thing last week in Ruby, just more complicated for absolutely no reason, for a component he was gemifying. Ruby code:
|
# ? Aug 6, 2013 21:47 |
|
That's a very common pattern for config files in ruby.
|
# ? Aug 7, 2013 00:01 |
|
DSLs like that are a big part of Ruby. The only horror there is that they used a yielded object instead of instance_eval, because it could be made into the (much prettier) below, a la Sinatra and a large portion of Rails.Ruby code:
|
# ? Aug 7, 2013 00:28 |
|
I don't have access to the code anymore, but this is a favorite story around the office: I work at a small custom software company that mainly deals with .NET. A while back we got a call from a medical records company in a mad frenzy about a particular issue they were having. This company had a public facing API that was used by their clients to request information about patients. However, occasionally the API would send back records for the wrong person. This is bad juju for medical records considering it's a huge HIPAA violation, so this company is desperate to fix it. The original programmer of the API left the company and anyone they tried to hire to replace him quickly left, so they eventually gave up trying. When they discovered this problem they decided to contact professional devs to fix it rather than attempt to get someone in-house again. We'd find out soon why they weren't able to keep anyone around. They sent us the source code and we started to poke around. We open the solution and find VB.NET, only one class, 70+ methods, with a file over 15000 lines long. That equates to about 200 lines per method. However, many of the methods were only a few lines long and just delegating to other methods, so it was really only about 10 methods that were contributing to the bulk of those 15000 lines. The worst offender was the method: code:
The problem was passed on to one of our junior developers, because good loving luck getting one of the senior guys to do it. He combed through the code but wasn't able to find the issue, so he called another junior dev over. They comb through the code together, but are still unable to find anything at then end of a full day. The next morning, a senior dev joins the two juniors and soon after another comes by. By lunch, 4 people are crowded around the computer alternately laughing and crying at the poo poo-tacular spectacle of horrible coding. The end of day 2 is drawing near when someone finally noticed it. code:
At the end of it all the fix was a 6 character change - remove the "Shared" keyword. We sent the source code back, billed around $10k, and walked away with a new hatred for both VB and the people who used to use it. Bognar fucked around with this message at 02:03 on Aug 7, 2013 |
# ? Aug 7, 2013 02:00 |
|
Another fun one from the world of embedded programming. Not so much a coding horror as an API Horror.code:
This oddity is documented, but in a pdf guide. And it's not coupled with a giant blinking neon warning that something very unconventional is going on here, which should be mandatory. Harik fucked around with this message at 02:48 on Aug 7, 2013 |
# ? Aug 7, 2013 02:40 |
|
Harik posted:Another fun one from the world of embedded programming. Not so much a coding horror as an API Horror. I've written horrible arcane castings before but this makes my head hurt. Embedded systems are scary.
|
# ? Aug 7, 2013 03:44 |
jQuery is the HIV causing horrible-code-AIDS to spring up everywhere. Through uncontrolled growth we now have just short of a hundred globally registered onClick handlers in our application page, most of which aren't relevant most of the time. I believe it even grows every time a new page is dynamically loaded, and it's absolutely killing performance. Don't blindly use the $(document).on('click', '.my [horrible=selector]', function(evt){...}) pattern, you will regret it.
|
|
# ? Aug 7, 2013 09:06 |
|
The horror with jQuery (and to a lesser extent Javascript in general) is that because it's obviously just about swishy easing, designers feel like it's their remit. Also people are awful at Javascript.
|
# ? Aug 7, 2013 09:48 |
|
Currently working on some multithreaded code that crashes when I remove a debug print.
|
# ? Aug 9, 2013 14:09 |
Zombywuf posted:Currently working on some multithreaded code that crashes when I remove a debug print. Whatever you use for printing might very well have some kind of synchronisation to avoid multiple prints stepping over each other. Causing your threads to sort-of synchronise at your printing points.
|
|
# ? Aug 9, 2013 14:30 |
|
Zombywuf posted:Currently working on some multithreaded code that crashes when I remove a debug print. Your code or someone else's?
|
# ? Aug 9, 2013 14:33 |
|
yaoi prophet posted:Your code or someone else's? Lets just go with "shared responsibility".
|
# ? Aug 9, 2013 14:51 |
|
Zombywuf posted:Lets just go with "shared responsibility". Translation: It didn't crash before (but there was a bug), but I changed something now, and it's broken more. This is how I imagine Zombywuf is on looking at my code:
|
# ? Aug 9, 2013 15:27 |
|
Zombywuf posted:Currently working on some multithreaded code that crashes when I remove a debug print. You mean you get to play with gdb all day? So jealous.
|
# ? Aug 9, 2013 15:54 |
|
tef posted:Translation: It didn't crash before (but there was a bug), but I changed something now, and it's broken more. Ah, yak-shaving.gif
|
# ? Aug 9, 2013 16:53 |
|
tef posted:Translation: It didn't crash before (but there was a bug), but I changed something now, and it's broken more. Nah, I've made it's behaviour more consistent. Before it only crashed sometimes, I made it crash all the time. quote:If anything it feels more like this
|
# ? Aug 9, 2013 16:58 |
|
So this is more silly than horror but: public static void ಠ_ಠ(string error) { throw new Exception(error); } public static void CreateFile(string path) { if(File.Exists(path)) { ಠ_ಠ("error: file exists") } File.Create(path) } Somebody's having too much fun. Works fine in C#, and php, phython and others seem to support unicode in code. Ruby does not, it looks like. (drat, code tags remove unicode! Sorry for lovely formatting) Zaphod42 fucked around with this message at 22:36 on Aug 9, 2013 |
# ? Aug 9, 2013 22:32 |
|
var ┻━┻ = new WhateverException() (╯°□°)╯︵ ┻━┻
|
# ? Aug 9, 2013 22:36 |
|
Zaphod42 posted:So this is more silly than horror but: Right to left override mark isn't a legal character.
|
# ? Aug 9, 2013 23:29 |
|
C++ code:
The worst "other developer" is yourself a year ago.
|
# ? Aug 9, 2013 23:36 |
|
code:
|
# ? Aug 9, 2013 23:51 |
|
|
# ? Jun 7, 2024 18:07 |
|
Haskell has Unicode variable names and custom operators: Prelude> let ಠ_ಠ = error Prelude> let a ^-^ b = a ++ " is more anime than " ++ b Prelude> let a ^-^ b = a ++ " is a better anime than " ++ b Prelude> ಠ_ಠ $ "evangelion" ^-^ "haruhi" *** Exception: evangelion is a better anime than haruhi
|
# ? Aug 10, 2013 00:05 |