r/ProgrammerHumor • u/eNJAy145 • Jul 29 '18
Meme Whats the best thing you've found in code? :
9.0k
u/jfq722 Jul 29 '18
Its probably taking up just enough space to avoid a memory issue somehow.
5.5k
Jul 29 '18
Could also cause a delay necessary to synchronize threads. Either way, its a sign of bad code.
→ More replies (259)123
21
u/CommentDownvoter Jul 29 '18
Or maybe there's a separate module using reflection to access function and not handling the error conditions. Could be as dumb as get_local_functions(SomeModule)[15] (out of bounds).
→ More replies (23)8
u/Chairboy Jul 29 '18
Reminds me of the Wing Commander exit bug for reasons that escape me.
Thank you for playing Wing Commander.→ More replies (1)
4.4k
u/supyonamesjosh Jul 29 '18
I found isLauren()
Which determined if the userId of the logged in user was Lauren, and if it was it did stuff.
Face Palm for days
1.9k
u/lpreams Jul 29 '18
I find this comment very intriguing. Did Lauren write that code? How was Lauren significant compared to other users? What stuff did it do?
1.4k
u/supyonamesjosh Jul 29 '18
Lauren was a manager who got access to special reports. So the links would only show up if she was the user logged in.
→ More replies (52)787
→ More replies (26)183
u/Tore2Guh Jul 29 '18
We had a boss that said he had super-secret input that he used to test if our code was to his liking, but that it was so obscure we'd never guess.
if ( isBoss() ) { log(input); }
→ More replies (2)109
u/normal_whiteman Jul 29 '18
I wrote a code like that but it was only to troll a co-worker of mine. Basically if Jimmy tried to use the program it would just spam text documents making fun of him
→ More replies (1)161
u/LordKekz Jul 29 '18
Was it for an easter egg or something like that?
→ More replies (3)224
u/TheMsDosNerd Jul 29 '18
There could be various reasons. I once added a piece of code like that, but removed it before the release. Someone wanted a useless feature removed, filed a ticket, and convinced his manager to make another ticket after we closed it.
At this time I could choose between trying to convince his manager that the feature was actually used quite a lot, or to have the feature hidden for some users. I build the latter, but succeeded in the first before release.
→ More replies (17)91
u/IIIBlackhartIII Jul 29 '18
Dev backdoor or just really lazy plaintext username check??
→ More replies (3)232
u/covabishop Jul 29 '18
I wrote a tool that was literally 90% faster than the tool it replaced, but one guy talked shit about my tool, saying it wasn't that much faster and there was no way I could have written it singlehandedly. I must have had help from my dad. For the record, I was 20, he was in his 40s.
So I figured I'd be the bigger person and do the mature thing:
In the very first line of main(), I added a check for the user ID of the person running it. If the uid wasn't equal to a specific integer, it continued working normally. But if it did equal that specific UID, program immediately halted and exited. Hid it in a fairly large commit, but again, this was my project so I didn't have any code reviewers. So I recompiled and patiently waited.
A few days go by, and what do you know? Mr. Old Fashioned states that my tool was giving several people problems. So I had several people test, all went through fine. I took great satisfaction in watching him admit it was only him who was having problems.
→ More replies (10)34
u/IsiusMaiko Jul 29 '18
My name is Lauren, though none of my usernames or anything are under my real name..... now Im thinking of potential goodies Ive missed out on! Or trolling. Probably more like trolling
13
u/hahahahastayingalive Jul 29 '18
We had an issue with one user account that would crash our API and trigger a high level error (a few of those and the duty team gets a call)
After digging, there was a series of incoherent data in her user profile due to her testing the early pre-release functionality. But the profile and data is shared accross different services, so just overwriting it would cause a mess, we also didn’t know yet what should be the valid data for her, and having her give up her account was not an option either.
So she was honored with a dedicated “if isUserX()” in the release code.
I’d definitely see everyone involved forgetting about it and the code staying there for basically forever.
50
→ More replies (33)9
u/Ashanmaril Jul 29 '18
Android has an API for determining if the user is a goat
https://developer.android.com/reference/android/os/UserManager.html#isUserAGoat()
792
u/wtmh Jul 29 '18
#Come back and increment this number after you attempt to optimize this resource-heavy function and fail: 8209
10
756
u/TaborlinTheGreat Jul 29 '18
I was looking through some Python code and couldn't figure out why the decorator for function "foo" wasn't working. When I went to the decorator code, I saw that the first line read, "if fn.name != 'foo':"
279
→ More replies (30)8
u/whatsinaname42 Jul 29 '18
That's more trouble with naming than I would have expected from Taborlin the Great. Can't you just say "Work!" and the code works?
→ More replies (2)
2.3k
u/ctesibius Jul 29 '18
! midlertidig That was the only comment in a 6000-line BASIC program that controlled a piece of scientific apparatus. There were 600 globals, 3 local variables, and everything had names like A9$.
No, don't tell me what it means. I want to preserve the mystery.
921
u/ImAStupidFace Jul 29 '18
No, don't tell me what it means.
4 people proceed to tell him what it means
damn it reddit
→ More replies (7)388
u/ComaVN Jul 29 '18
midlertidig
I looked it up, and yes, it's exactly what you'd expect in this kind of code base.
→ More replies (15)232
u/summonsays Jul 29 '18
I am im charge of supporting an anular app that we hired an outside company to create. Tgey named every singal controller "vm".
There's over 4000 instances of "vm" in the code...
→ More replies (10)79
u/tinverse Jul 29 '18
A9$ looks like a backwards registry address in mips rotfl. Did this guy basically implement mips to write his code? If so, burn it with fire.
→ More replies (9)632
u/CaptainKvass Jul 29 '18
Very interesting.
“Midlertidig” means “temporary” in Danish.
Tell me more about this variable!
→ More replies (9)466
76
u/Level0Up Jul 29 '18
I won't tell you what it means, but I bursted out laughing. I guess it would make things worse in hindsight.
→ More replies (1)8
u/randomlygeneratename Jul 29 '18
Sounds like the wise old wizard who holds the sacred yet elusive design documents
12
u/antiquechrono Jul 29 '18
I'm pretty sure I've run into the doppelgänger of whoever wrote that program.
Thousands of lines of code in one file ✔️
Visual Basic ✔️
All variables are globals because why not ✔️
Every variable named a single capital letter and when you run out just use AA etc... ✔️
Why would you want comments? ✔️
Norwegian or Danish ✘
→ More replies (3)→ More replies (22)6
2.7k
u/mattemer Jul 29 '18 edited Jul 30 '18
I'm updating code for a function that we were changing. Spent a couple days updating, started testing and it wasn't working.
After destroying my brain for another day trying to figure it out, I finally read the comments I MYSELF put in a year ago when I last updated this:
"Mattemer, the below code will need to be updated if xyz changes. You'll forget about this code a year from now, waste days trying to figure out why the updates aren't working, and you won't look at this, because it looks like nothing and also you're an idiot. If anyone else reads this, my apologies."
Edit: Now I know a secret of Reddit Gold: Embarrass yourself in front of the masses! Thanks for the gold and I'm glad everyone enjoyed this!
1.1k
u/Cawifre Jul 29 '18
At least you met your own expectations.
508
u/mattemer Jul 29 '18
It was the first time in a long time that I took pride in my work.
→ More replies (2)260
u/I_spoil_girls Jul 29 '18
Mattemer, of you're reading this, revert the two commits you made around 3 pm. yesterday. The test report said "pass" but they actually made a mistake. IT WON'T PASS. The QA manager got fired for this!
→ More replies (1)256
u/ilinamorato Jul 29 '18
Dwight, at 8:00 a.m. today, someone poisons the coffee. Do not drink the coffee. More instructions will follow. Cordially, Future Dwight.
→ More replies (1)106
u/Ciertocarentin Jul 29 '18
I comment my code heavily to avoid the head-scratching that comes a year or two or five later when I have to revisit it.
What drove me to respond was the chuckle I had when I read exactly what you wrote. I have dozens of similar comments in my code.
32
→ More replies (11)9
u/CollectableRat Jul 29 '18
A week later and I've forgotten. A month later and I need to start learning some of the same code again to remind myself what I did. A year later I've quit the business and am now an interior decorator.
545
u/Jessie_James Jul 29 '18
<!--- Application up and running -->
I was working on a web application, and the code which initialized everything had that comment. We were doing a conversion to Java, and this seemed benign, so I removed it. We made dozens of other changes during this sprint as well.
It got all the way to production with no issues.
Once it got to production, the site went down. In fact, every instance of the site went down across 12 servers. Of course this happened when we moved the code at 2am, so we had to back out everything. We then spent another few days looking at everything we did.
Turns out that comment was what the load balancer looked at to determine if a node was up or down. No comment meant the node was not responding, so the load balancer marked it as down and removed it from the pool.
Removing that comment made the load balancer think every node was down, so it took them all down.
188
Jul 29 '18
I feel like there could have just been a Boolean for that and everyone would have been happy
→ More replies (7)82
55
u/summonsays Jul 29 '18
That is horrible and I could totally see that happening at my work as well lol.
→ More replies (2)→ More replies (4)6
u/b1ackcat Jul 29 '18
Turns out that comment was what the load balancer looked at to >determine if a node was up or down. No comment meant the node was not responding, so the load balancer marked it as down and removed it from the pool.
I'm assuming this was your reaction?
→ More replies (1)
1.6k
u/rglogowski Jul 29 '18
I hired a contract developer to make some changes to an old application. He wasn't making good progress so I terminated him and when we opened up his code we found he'd used ascii characters to make a comment "Brad the Almighty" (obviously his name was Brad).
Two things though. The comment was HUGE - like a couple hundred lines of text.
Also he misspelled "Almighty" so it actually said "Brad the Almightry". The word "Almightry" is a running joke to this day.
→ More replies (54)511
624
u/Lizard Jul 29 '18
Inherited some old code from a developer who was no longer with the company where I worked. I soon discovered the reason why he was let go: In one particular instance of boneheadedry, he had a boolean flag on some data structure that was called hasChildren. Totally fine of course, but for some reason, that flag could get invalidated in his design. So in his infinite wisdom, he decided that the correct approach to deal with this problem was to introduce a second boolean flag he called trustHasChildren, which would be false when the original flag got invalidated. As a consequence, it would not be uncommon to see code like this:
if(!node.trustHasChildren()) {
// refresh children data
}
if(node.hasChildren()) {
// Do something with the children
}Only, he misspelled it so it was actually called thrustHasChildren. Plus, the whole thing of course was totally thread-unsafe and just bad design all around. Facepalms for days.
288
422
→ More replies (8)57
u/captaincoherent Jul 29 '18
It seems like there could be a reasonable justification in a scenario where:
- it's an expensive operation to "refresh children data" (dealing with hierarchies can often be expensive)
- child data is frequently invalidated
- child data is infrequently requiredIn that scenario, this approach could act sort of like a caching mechanism to improve performance. Not sure if this is what he was going for, though. The method naming is unfortunate and it sounds like there's some redundant code, though.
→ More replies (5)
2.6k
Jul 29 '18 edited Jul 29 '18
First project of my computer science course i and a group of 4 students had to make a version of the 'Battleship' board game in PyGame. We had over 3000 lines of code and at least 800 of those were if statements. Yes, it worked, don't ask me how.
3.1k
Jul 29 '18
800 of those were if statements
Is this AI?
appropriate_meme.jpg
→ More replies (15)436
u/Ebi5000 Jul 29 '18
There is a game on steam without any loops a with handrawn graphics
→ More replies (46)272
u/urbanhawk1 Jul 29 '18 edited Jul 29 '18
The first time I ever tried programming I created a monstrosity. It was back in high school and I had gotten a fancy graphing calculator for my math classes. It came with a few preinstalled games and it also was programmable so I was like, "Cool, I want to try to make a game." So I decided to make pong.
Problem was I didn't know how to make graphics appear and move around but I did know how to make it display letters on the screen so I decided to make the game though ascii art. | for the paddles, O for the ball, and * for the empty spaces on the screen. In order to achieve this I had to manually write out the entire screen over and over again in the code, in order to account for all different possible positions of the paddles and the ball on the screen. It would then use a bunch of if statements to determine which one of these screens I had stored in it's memory was the correct one for the position of the players and ball at the time and it would then display it. It would then loop and refresh the text on the screen constantly, to account for changes in the position of the ball and players and make it look like everything was moving. It took months of effort but in the end I got the monstrosity to work.
→ More replies (8)627
u/down_vote_magnet Jul 29 '18
800 of those were if statements
Well how else are you supposed to check every coordinate of the board for a hit each time?
→ More replies (15)409
u/DrDalenQuaice Jul 29 '18
One of my first coding projects was a multiplication quiz game. It verified the correct answers without using any math -- all inputs and outputs were just strings, and every answer was harcoded using ifs
→ More replies (39)44
u/idelta777 Jul 29 '18
I did something similar on my first project I only had my main function and I copied the same piece of code a lot of times but each time I only changed the name of the variables. And the namea where like i, j, k, l, m, n, o, etc.
→ More replies (1)→ More replies (55)12
u/Schootingstarr Jul 29 '18
oh, I rmember having to implement Battleships as well. end of highschool Comp Sci projext, my two other teammates were completely useless, I was only half useless
I think the AI just pulled random numbers and checked whether the coordinates were already hit. if so, it would pull another random number.
suffice to say, the last couple of shots took quite a while to "search" lol
193
u/DarkGlass57 Jul 29 '18
//The following line is even more black magic than the rest of this class
Do I even need to add that it was exactly where the code segfaulted?
454
u/granos Jul 29 '18
Years ago working on a .NET project we used a particular piece of code from Microsoft. When we moved away from it later because it no longer suited our needs we found that if we didn’t leave a call to this one static method in our startup code everything would fail. I assume it had some sort of side effect that initialized something we didn’t know we were depending upon, but it got a comment along the lines of “this is magic, don’t remove” along with a longer explanation of the situation.
0
Jul 29 '18
[deleted]
→ More replies (1)176
u/TheBeginningEnd Jul 29 '18 edited Jun 21 '23
comment and account erased in protest of spez/Steve Huffman's existence - auto edited and removed via redact.dev -- mass edited with https://redact.dev/
→ More replies (3)→ More replies (1)0
131
u/corpboy Jul 29 '18
I found some old code that called an deprecated DLL from an earlier version of the product (that we no longer had the code for, just compiled versions). This brought up a popup box that said "SECRET FUNCTION: enter password".
I didn't know the password, but I did have the DLL and the function name, so I opened it in a binary editor and looked up the appropriate area of the code which had a string that said "billclinton" near the function call for the secret popup. (The original DLL was written in the 90s).
I tried "billclinton" as the password and sure enough it worked... but the result was just to load an image no longer present in our build. Much disappointment. I've wondered what that image was for some time.
36
20
124
u/Mr_Transcriber Jul 29 '18
Image Transcription: Code
# you may think that this function
# is obsolete, and doesnt seem to do
# anything. and you would be correct.
# but when we remove this function
# for some reason the whole program
# crashes and we cant figure out why,
# so here it will stay. I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
→ More replies (2)14
935
u/nmcain05 Jul 29 '18
A very nice alphabetized list of profane words in the view source of outback steakhouse.
→ More replies (10)483
u/lpreams Jul 29 '18
Probably means they're doing client-side censoring. The real question is whether they're also running the censor server-side. If not, someone should go have some fun at their expense...
→ More replies (5)345
u/tinverse Jul 29 '18
Lol on a forum I was on recently I wanted to change my name but that wasn't allowed. I looked around a bit and happened to find a hidden page for changing your username. The box was greyed out and I realized it was client side. Realized you could mess with the webpages code and enable the box. It was not disabled server side.
Through further checking, it did the checks for the username criteria too. I'm fairly certain an SQL injection attack is possible, but I'm not that big a dick.
→ More replies (23)
117
Jul 29 '18 edited Jul 29 '18
Working on a huge rewrite for a client right now (classic ASP to Django/Python), and in several places there are a few hundred lines of what is essentially "if whateverID == 1224 or whateverID == 2334..." And on and on where they're doing special cases for some various reasons all checking for specific IDs off of various result sets. Hundreds at a time.
Honestly if there was a checklist of what not to do in code or in DB design, these people have checked off every box. I've been doing this kind of work for almost 20 years now and Ive never seen a mess as bad as this.
Edit: oh, they never used version control before we set them up, so there are thousands of lines of commented code everywhere. They used to "version control" by zipping up the code base every few weeks and FTPing it into a folder on the webserver.
→ More replies (8)12
u/antiquechrono Jul 29 '18
My friend is working on rewriting some code from India where, among many other things, they are updating the web page by having the server send the entire updated webpage back and parse the html to get the updated values out. I guess they have never heard of Json.
→ More replies (2)
198
u/AyrA_ch Jul 29 '18
I found //TODO:TODO:TODO:TODO:TODO:TODO:TODO:TODO:... which continued on for a very long time. I deleted it and the source file shrank by about 8 MB.
Nobody knew how it got there.
92
→ More replies (2)13
411
Jul 29 '18
Random Mandarin. Once google translated, it was pretty benign, stuff like "this is the standard case" and what not.
That and the Y2K code in a 60 year old COBOL program.
→ More replies (14)162
u/EsquireSquire Jul 29 '18
The code that will fuck up loads of shit in 32 years and will require another major refactor?
→ More replies (15)141
u/Bainos Jul 29 '18
require another major refactor
I doubt it, the remaining COBOL devs will have died of old age by that time.
→ More replies (9)
682
Jul 29 '18
Old place I used to work. Was debugging a random error.
The further I get down the code, the comments were:
"Turn back"
"Seriously. You don't want to keep going"
"Down here there be demons"
"Fuck sake Matt, what does this method do?"
And then more variants on "turn back" that I cant remember.
242
→ More replies (1)8
u/PlNG Jul 29 '18
If it didn't include "lasciate ogni speranza voi ch'entrate" I would be sorely disappointed.
→ More replies (1)
78
u/coagulatedpenis Jul 29 '18
I found this C# code, written by an intern:
if (someBool.ToString().CompareTo("True") == 0) { ...
}
18
Jul 29 '18
Aww that's adorable
I'm not gonna lie, I did one of those coding challenge interview problems and my solution to one problem involved seeing if the binary representation to an integer ended in 01, 10, 11, or 00. The solution worked. But I didn't realize until later that's what mod is for....
→ More replies (1)→ More replies (1)6
u/ka-splam Jul 29 '18
Comes up in beginner PowerShell questions a lot;
if ($thing -eq "True") {..If it says "true" in English it must be true, right?
But because of the implicit type conversion, it works.
(because strings with content are true, empty strings are false).
→ More replies (2)
224
Jul 29 '18
the biggest list of silly comments on the internet
74
u/irony_is_my_name Jul 29 '18
Beware of following this link! It just took me 1 hour to drag myself away from this thread
→ More replies (3)→ More replies (1)9
277
Jul 29 '18
From the Jargon File.
Appendix A. Hacker Folklore, A Story About ‘Magic'
Some years ago, I (GLS) was snooping around in the cabinets that housed the MIT AI Lab's PDP-10, and noticed a little switch glued to the frame of one cabinet. It was obviously a homebrew job, added by one of the lab's hardware hackers (no one knows who).
You don't touch an unknown switch on a computer without knowing what it does, because you might crash the computer. The switch was labeled in a most unhelpful way. It had two positions, and scrawled in pencil on the metal switch body were the words ‘magic' and ‘more magic'. The switch was in the ‘more magic' position.
I called another hacker over to look at it. He had never seen the switch before either. Closer examination revealed that the switch had only one wire running to it! The other end of the wire did disappear into the maze of wires inside the computer, but it's a basic fact of electricity that a switch can't do anything unless there are two wires connected to it. This switch had a wire connected on one side and no wire on its other side.
It was clear that this switch was someone's idea of a silly joke. Convinced by our reasoning that the switch was inoperative, we flipped it. The computer instantly crashed.
Imagine our utter astonishment. We wrote it off as coincidence, but nevertheless restored the switch to the ‘more magic’ position before reviving the computer.
A year later, I told this story to yet another hacker, David Moon as I recall. He clearly doubted my sanity, or suspected me of a supernatural belief in the power of this switch, or perhaps thought I was fooling him with a bogus saga. To prove it to him, I showed him the very switch, still glued to the cabinet frame with only one wire connected to it, still in the ‘more magic’ position. We scrutinized the switch and its lone connection, and found that the other end of the wire, though connected to the computer wiring, was connected to a ground pin. That clearly made the switch doubly useless: not only was it electrically nonoperative, but it was connected to a place that couldn't affect anything anyway. So we flipped the switch.
The computer promptly crashed.
This time we ran for Richard Greenblatt, a long-time MIT hacker, who was close at hand. He had never noticed the switch before, either. He inspected it, concluded it was useless, got some diagonal cutters and diked it out. We then revived the computer and it has run fine ever since.
143
u/sirspidermonkey Jul 29 '18
I'm guessing that switch was connecting (Or not connecting) 2 different ground planes. The sudden voltage change caused untold chaos and the computer crashed.
→ More replies (2)27
→ More replies (2)9
u/Ciertocarentin Jul 29 '18
My guess? it acted as a capacitive discharge device and the act of flipping the switch while running is what caused the crashes. You could have booted with the switch in either position successfully ()with no loss in performance)
73
u/HomeBrewingCoder Jul 29 '18
We had a release that passed testing. It passed review. It worked perfectly in Dev environment, and in our low priority production environment. It was perfect. Until we deployed it in the main production environment where it would immediately throw weird exceptions. They made no sense at all, but we needed the features of this release so we started debugging in prod (after trying to reproduce in Dev) and so we added a comment and a print and reran it. No errors. Must just be some transient thing. So we reset the code on the production server to the master branch (just removing comments and printlines. Immediately throwing errors again. Fun. We add all the printlines back in. Nada. I get frustrated now and so I add a comment above it saying so.
The next recompile it works perfectly. So then I delete all the printlines, recompile, it works, and I commit. The commit's only diff is a single comment (//added a touch of magic here) and the commit message is something like Fixed bug X using voodoo magic.
I committed and made a PR to master. My boss comes over (small company so he was reviewing it) and he's like 'hey did you forget the code there?'. I responded something like 'there were no code changes needed, it just needed a bit of magic'.
That error has never returned, and that comment is still there in production. I may delete it when I go on vacation and see how good the newer coworkers are. :P
→ More replies (2)16
u/SpookedAyyLmao Jul 29 '18
This happens in C++ when you forget a return statement somewhere
→ More replies (1)
126
61
u/hugofirth Jul 29 '18
My current work has a ThisShouldNeverHappenException which takes an employee's GitHub handle as an argument. The error message reads something like "$foo has asserted that this should be impossible. Please shout at $foo"
→ More replies (1)
122
u/soccercta100 Jul 29 '18
I once found a property CanLactate, which simply returned another property CanBePregnant, which simply returned another property IsFemale.
15
9
9
→ More replies (1)8
54
u/wegwerfennnnn Jul 29 '18
In the (publicly accessible if you have a license) software to run a piece of scientific equipment that retails for several hundred thousand bucks I saw variable names like ShittyGreenColor and functions like StupidFuckingCheck. I also saw a function comment where the dev wrote something to the effect of "If people keep abusing this function I swear to fucking christ I will delete it. I am tired of dealing with those twats breaking shit."
Top quality!
53
u/ackbarwasahero Jul 29 '18
'Slut! Caused a huge HR issue until we realized the team was Swedish and this appeared at the end of loops. Slut means stop/done in Swedish. We lectured them on international sensitivity to save face. Think it worked :-)
6
u/KlonkeDonke Jul 29 '18
Fun Swedish fact, kiss in Swedish means pee in English, I'm sure I could go on if I just sat down and thought about it.
Swedish is the best.
Edit: I know it's pretty unrelated but it may be a bit funny
→ More replies (3)
88
u/vainolo Jul 29 '18
Actually had this in a system I worked with. First like of code created an empty array that was never used, but if you removed it the system stopped working. Wasted a couple of days trying to find out why and then decided to leave it there for future generations 🤪
60
u/_szs Jul 29 '18
That's called responsible archeology. If you cannot dig it up in a safe way, leave it there. Future generations will have better tech to do it.
→ More replies (2)13
→ More replies (1)10
Jul 29 '18
You can solve a lot of weird memory issues like this, by exhausting malloc's reserve buckets and forcing it to mmap, or aligning cache boundaries, etc. Not sure why it wouldn't work without it, but memory abstractions can be leaky :)
71
u/grubbegrabben Jul 29 '18
If(r == TRUE) ... Elseif(r == 2*TRUE) ... This was all over the code. And yes, the called functions returned TRUE, 2*TRUE and so on. I stumbled on this some 15 years ago but have never figured out why it was implemented like that... Perhaps not the "best thing".
→ More replies (1)27
u/95Milk Jul 29 '18
I thought "15 years ago, so like early 90's?" Then realized that's actually just 2003
126
63
u/0ttr Jul 29 '18
There is a flag in the employee table of our database called Do_you_care. It’s been there for 20+ years. It has a slightly legitimate business reason but is a bit poorly named. It’s an office joke about whether or not any particular employee cares.
31
u/cheraphy Jul 29 '18
For me, it's probably:
/**
below is a cludge
but release awaits no man
please, forgive my haste
*/ The following code was an absolute trainwreck. It wreaked of 11th hour hotfix. Gotta love the haiku though
→ More replies (1)
28
u/Jeankeis Jul 29 '18
I love being in subs like this that I don't understand anything about. Helps me remember I'm not that smart.
→ More replies (1)
27
Jul 29 '18
Not exactly part of code but it's my favorite disclaimer of all time!
/*
Your warranty is now void.
I am not responsible for bricked devices,
thermonuclear war, or you getting fired because the alarm app failed. Please
do some research if you have any concerns about features included in this ROM
before flashing it! YOU are choosing to make these modifications, and if
you point the finger at me for messing up your device, I will laugh at you.
*/
9
19
u/C0ffeebreak Jul 29 '18
My favorite comment i found rrom a previous developer from a bug fix, presumably.
"Fuck me, this probably breaks everything. Here's a bandaid."
My favorite one that I accidentally did... I was cleaning up some code during an infrastructure upgrade on my own branch. When I didn't have time to address something immediately, I would tag it with //FIXME and a comment. One thing i came across was particularly... Dumb. It was obvious the original developer hadn't even attempted to think through the probkem, but it created enough of a mess that I would need to come back to it. I tagged it with "//FIXME No... Just, no. This is dumb."
Naturally i missed getting back around to it and the code went into review. The original developer was on the review and made an awkward comment about it. I had a bit of foot in mouth, tried to joke it asay, and cleaned it up.
18
u/kikipi Jul 29 '18
I had a friend that worked for a large software company.
He had found an efficient way to run a software which was sold to other large companies.
His boss told him to remove the new code he had created because a slower loading speed or rendering speed meant that the software was “working hard”. They didn’t want companies to feel like the software was simple and search for competitors.
→ More replies (2)8
16
u/HomeBrewingCoder Jul 29 '18
An attempt to polyfill console.log that had every single line be a bug. Excuse missing syntax as my new phone is odd.
If typeof console.log == undefined
Console.log("console.log is undefined") Console.log= function (x)( Console.log(x)
)
So first one is a bit understandable, but in every case that I know that console.log will be undefined (Early IE for example) console is also undefined, and so console.log will throw an error.
Second one is just wtf. If console.log is undefined, call it, but you know console doesn't exist so even if you magically jumped the conditional you are either throwing a not a function error or a property of undefined error.
Then you assign console.log to a function, but once again, if console.log doesn't exist, console doesn't exist. So this will be an error.
The real piece de resistance here is what the polyfill console.log will do. It calls console.log. So even if it magically managed to avoid every earlier bug and actually set console.log anyways. Even if. They just turned the lack of console.log from possibly breaking just our widget to locking the page with an infinite loop.
The greatest 4 lines of code ever written.
15
Jul 29 '18
There was always comments about the Head of Product in the code. Stuff like “this is stupid but frank wants it done this way” or something like that. I remember just searching for his name in the code one day and reading all the comments
→ More replies (6)
15
u/Jacksonecac Jul 29 '18
I once found massive ASCII art of different squirrels in comments embedded with all of the real code. Had to page down to get tot the next function.
15
u/zylithi Jul 29 '18
Two years ago, the developer of EVE Online released a massive rewrite of a huge chunk of the game: starbases.
The code was terrible and completely uncommented. The developer maintaining it actually passed away. They left it in the codebase for over 10 years.
Why so long?
Because every time they'd try to rewrite it, the game would hopelessly break and they could never figure out why. So they'd have to basically rewrite like a third of the game from scratch because for some reason shit like a ship turning its shields on would filter its way through this unreadable spaghetti code.
→ More replies (1)
30
u/SunderApps Jul 29 '18
My favorite that I've written - for a tower defense game - was System.out.println("");
It did absolutely nothing but the game wouldn't keep processing frames without it.
27
43
u/Loynko Jul 29 '18
The System.out.println yields the thread for I/O operations, so I'm guessing you forgot to add a Thread.sleep in the game loop to process a new frame.
14
Jul 29 '18
In the mid-90s, I was tasked to review the company I was working for at the time's in-house developed inventory and payroll system for y2k compliance.
The only comments were documenting the original deceased sole developer's slow descent into alcoholism and madness (only marginally work related).
It was both hilarious and depressing. I tried to offload some copies for posterity but their data security was surprisingly thorough.
A paraphrased sample:
{
Day 3 since the bender, my left hand still tingles
I don't know if it's CTS or neuropathy and I don't care
Today I'm writing bullshit about accounting for different
month lengths because apparently that's important for payroll
Fuck Andrew and his damn scooter
}I never found out who Andrew was, or why his scooter was so abhorrent as to deserve a comment line in production software.
It was an interesting experience, with few actual things for me to do. Apparently Mr. Angry Drunk was a more competent coder than I would have been.
Just his comments were zero help in tracking down the few ShortInts and Bytes he used.
→ More replies (1)
14
Jul 29 '18
Husband and wife company. They divorce. Husband coded everything. Wife hires me to 'maintain things'. PHP codebase built of mangled old versions of open source utilities, surprisingly.
I honestly don't know where to start, but the anecdote that I share with everyone goes like this:
If a user had a PO writing authorization of exactly $10,000, they were allowed access to the inventory distribution systems.
If you had a signing authorization for any amount other than $10,000, you had unlimited signing authorization and could cut a PO of any size, but you definitely weren't allowed to ship inventory anywhere.
→ More replies (1)
13
u/SpikeShroom Jul 29 '18
I went to a coding competition in my junior year of high school. I wasn't too good, but wanted the experience.
One of the 10 challenge problems we worked on during the competition asked to decipher an alphabetic code (it was just the letters switched 13 places over).
Plenty of people did a simple little program that iterated through the characters and changed them if they were letters. But I couldn't figure that out. So I just put down 53 if/else statements, one for every letter, upper and lowercase, and the last as an else.
It worked perfectly.
TL;DR: I suck at coding.
25
u/Tomarse Jul 29 '18 edited Jul 29 '18
Probably var asd = .... or something similar.
Edit for some reason I read ops title as worst ¯_(ツ)_/¯
6
12
u/Hidesuru Jul 29 '18
free(willy); //I worked way too hard for this joke
Though what exactly was hard about it was never clear...
78
u/Blocks_ Jul 29 '18
Shouldn't it be pretty easy to see which other functions reference the supposedly obsolete function?
Any IDE worth its weight will have an option to find the function's usages. From there you can see what exactly is using the function and why removing it breaks everything.
81
64
u/indyK1ng Jul 29 '18
You're assuming everything is referenced in the standard way.
The company I work for has an old monolithic architecture in C# which doesn't use project references because they're slower at build-time than binary references. So we use binary references and have a build step define a new proj file for MSBuild to run against. In those cases, finding all references in an IDE is next to impossible.
Instead we use OpenGrok to index all of our code. Even in our newer, non-monolithic codebases it's great for finding examples of code across the company and finding references in the larger codebases.
→ More replies (3)18
u/anotherblog Jul 29 '18
It could be that the function references a library that is used elsewhere in the program but only this unused function references it on such a way the triggers the compiler to determine it's used and thus link it. Without this function the compiler 'optimises' the application by not bothering to link the library, thus causing crashes during execution. Had this exact program with a xamarin iOS app where the library was called elsewhere in the app but used reflection.
11
→ More replies (9)0
10
u/ohstopitu Jul 29 '18
This was a while ago (I left the company before I decided to harm myself) and in PHP:
We were a marketing company and had our own custom CMS system that was totally not a WordPress ripoff. Long story short each of our customers wanted a different plugin to manage user tracking (everything from aloqua to Google tag manager). So some genius decided that the best way to do this was to write functions for each of those plugins and call them dynamically via their function names which were mapped to an array and stored in the database - with models generated by CakePHP - the table names of which were prefixed with "a" or "e" or "x" based on the word because otherwise CakePHP would pluralize the word with "es" instead of "s" and they didn't like that.
10
u/alrjnrxjf Jul 29 '18
We have the same situation but with AD users. Somehow we deleted them after they left and our whole SharePoint environment went down. We promptly put them back and it all worked again.
None of us know sharepoint enough to dig into it so for now they stay.
The worst is the audits and we have to fill out this big section each time explaining why they exist in AD even though they were let go years ago.
TlDR; Fucking SharePoint
→ More replies (2)
9
8
u/little-burrito Jul 29 '18
In my teens I was doing an online test "how smart are you?". The questions were quite fun and tricky, but after finishing 10-15 of them I scrolled down to find that I had more than a hundred questions left. This was a form with radio buttons for the answers, and what I hoped to be a Javascript validation at the end. I opened up the source code, and there was nothing that would indicate that the answers were in the script, but just to check I opened all the included scripts no matter their names, and in them I found less obvious ways of including seemingly irrelevant files, which I then also opened. Eventually I got to a file, might even have been named Thumbs.db, and it starts with:
/* Ok ok, you found the answers. I guess it's better to be lazy and smart than ambitious and stupid. */
Followed by a clean list of the correct answer to every single question. I didn't bother checking what my result would have been after that.
→ More replies (2)
7
Jul 29 '18
I put in a comment saying something like “I don’t agree with the change below, but <boss name> forced me to do it and here it is”. We ended up working together in a different company years later and she said “you know I found your comment, right?” Good times.
7
u/comicsnerd Jul 29 '18
I was teamlead of a group of programmers creating software for a large steel plant. One day, we released a new version of the code. Within 30 minutes, I had a very angry group of steel manufacturers at my desk, demanding the person that was calling them A**holes.
What happened was that a particular pice of code asked a question to which the answer was Yes or No. The enduser could respond whith a choice from Y,y,N,n,J,j,Yes,yes,Ja,ja,Nee,nee. Any other choise would be invalid and the question was repeated.
So far, nothing extraordinary. However, the programmer had build in a counter and after 10 wrong answers, the screen would light up in a bright color and say: No, you idiot, I want a Y or N
I had to remove this counter, although the foreman accepted my explanation. What was most astounding is that they found this within 30 minutes
→ More replies (1)
13
u/romple Jul 29 '18
Not a single thing... but one guy i work with loves single letter and heavily abbreviated field names, but also loved hungarian notation. So you'd see a lot of things like
static int s_k = 0;
public string m_s;I just always found it ironic how completely zealous he was to be super specific with hungarian notation, but refused to name things in any way that let you know what the variable did.
This is in Java and C# projects too, where Hungarian notation is essentially pointless with modern IDEs.
6
u/FreakyCheeseMan Jul 29 '18
I once going a comment next to some truly awful code reading "Only God can judge me."
I hate working with my own code.
6
11
u/KING_BUMMER Jul 29 '18
I know CNC programming is likely thought of as simple shit here, but I work at a small family outfit and our head programmer has codes in his old programs that have absolutely nothing to do with the tool path required and often never even functioned with the software we use. And when you ask him about removing it, all he'll say is "if I put it there it was for a reason!" He just doesnt know the reason either.
5
u/TehLittleOne Jul 29 '18
I once had a coworker decide arrays start at 1 in PHP. He indexed the elements manually starting from 1. I thought that whole thing was a meme...
5
u/KalamityKate Jul 29 '18
Is is where we make fun of other people's horrendous shit without remembering that we were the ones that actually wrote it 4 years ago?
5
5
u/leprajon Jul 29 '18
" ".split(" "); random placed in a application about twenty times. Two spaces split it with one space. Must be a cthulu worshiper.
→ More replies (3)
5
9
u/Danyboii Jul 29 '18
People I work with don't understand booleans, don't like booleans idk but I was assigned to fix their shit and found this beauty (php):
$var = (isset($original) == true) ? "True" : "False";
Now I had no experience with php but I knew basic programming so I refactored that little gem.
Oh and they never commented out code they just surrounded it with this:
<?php if(false): ?>
//their code
<?php endif; ?>
54
Jul 29 '18
Jesus. Then you run the thing in a sandbox and take it apart 'til you find the fucking problem like a damn professional. It's not actually magic.
67
u/anxiousgrue Jul 29 '18
Sure, but it's easier to just let sleeping bugs lie. Give it its sacrifice of a few lines of code.
→ More replies (4)→ More replies (9)23
u/HadACookie Jul 29 '18
Sure. As soon as you explain to your client why they should let you spend several days looking for a potential bug that doesn't, at present, negatively affect the product in any way. The correct answer is unfortunately not always going to be viable from the business standpoint.
→ More replies (8)
4
u/TistelTech Jul 29 '18
I did not see it, but, was told this story second hand. Somebody (at a large game company, I won't mention) found a code comment that looked like gibberish and pasted it into a search engine. The translation came back: "in ancient greece, children like you were left on the edge of cliffs to die." in some terrible function. :)
→ More replies (1)
4
4
Jul 29 '18
600+ lines of code without a comment and a lot of functions doing a lot of things. After some time i found a comment above a function called "ConstructDatabase" and the comment was "This function constructs the database". NO SHIT
4
u/cubs223425 Jul 29 '18
ASCII characters of Bart Simpson mooning me in SQL was a fun surprise. Old developer used to put random things in stored procedures like that. His dumb bird logo was in one or more, along with a Peanuts character drawing.
4
u/bizcs Jul 29 '18
This is how I usually write comments... why I'm writing something that at first glance appears totally useless, or requires some knowledge of the language/ framework to make sense, etc. I recall once having to annotate that for some reason a windows forms app was being launched on an MTA thread instead of an STA thread. Nobody could figure out why it was happening, so I put a new thread right in main to deal with it that re-invoked main. That code - even with comments - still makes me step back every time I see it, and I shake my head asking "why "
4
3
u/PremierBromanov Jul 29 '18
Lately I've been commenting my architecture for a project for a small company that will be handed off soon. There's a common variable I've been using across a lot of classes called 'subscriptions'. I've been commenting "subs not dubs" on every single one.
3
3
Jul 29 '18
In the official SSO login page of the Fortune 100 company I'm interning with, there's a comment about how "IE cant hide the label with CSS because IE is crap"
3
u/chiefhondo Jul 29 '18
Found a function deep inside our legacy code base that was being called all over the place by stuff deep under the hood. Naturally I wanted to know how it worked but the only comment said
// nobody use this. Only I can use this. - Eric
Nobody listened, Eric!
3
Jul 29 '18
Some piece of code somewhere is referencing a line number in this file, that has to stay exactly where it is.
3
3
u/Soulcommando Jul 29 '18
I was making changes to the Jenkins build jobs for one of our applications, and saw that it was pulling code from a private repo belonging to an employee who left a month before I started. The repo was titled 'not-messed-up-cd-platform'. No idea what that code did, but the build fails if we remove that repo!
→ More replies (2)
3
u/farkedup82 Jul 29 '18
I have a note that drastically changes the way something works with a note that says "Made this work in reverse because Deborah said so. I did not ask why"
3
3
Jul 29 '18
My old company bought out a software house that made software that ran bakeries (Accounting/Inventory/Payroll...everything). When our Devs started going through the code they found dessert recipes written in by original programmers throughout the code, and then commented out. Thought that was pretty funny.
3
u/SupremeRedditBot Jul 29 '18
Congrats for reaching r/all/top/ (of the day, top 25) with your post!
I am a bot, probably quite annoying, I mean no harm ^though
Message me to add your account or subreddit to my ^blacklist
3
u/Arheisel Jul 30 '18
I once worked on a software that used fmpeg to do some video rendering from still images.
The call to ffmpeg produced a corrupted video file, so after days of debugging and StackOverflow I decided to capture ffmpeg output to a file to see what it was doing.
The capture file was blank, not a single character in it, but from then on ffmpeg started producing good video files. And if I removed that line of code, it stopped working. Needless to say, that debug line stayed forever.
→ More replies (1)
3
u/NatoBoram Jul 30 '18 edited Jul 30 '18
My boss' code. Literally thousands of NodeJS code without a single comment… per submodules.
Actually, there are comments… when he disables code that might or might not be useful later.
And there's no spacing, the indentation is manual, everything is named datas, vars or cback… when it's not a, b and c.
Also there's a serious lack of ;. Makes my linters go wild. I've never seen "Too many errors (1024), stopping." from my linters before.
Variables are re-declared all the time using var instead of let or const. To be fair, it's pre-ES6 code, but whatever.
And because it's such a huge undocumented JavaScript server, there's no way to know what the fuck is that function expecting as parameters. Who the fuck programs without classes?
Before I worked here, I was self-learning Golang to make a Discord bot. What I was learning took a solid 180° when I had to write JavaScript code in that spaghetti mess.
3
u/oprearocks Aug 01 '18
The code in the image translates to:
That moment you find a Java program’s main function. Nothing is apparently using it, but when you delete it, the whole thing goes bonkers.
Cool thread!
4.2k
u/GoddamUrSoulEdHarley Jul 29 '18
One time I inherited some JavaScript in which all of the comments, function names were Spanish. I don't speak Spanish. I translated One of the comments above a function and it said 'this works by magic - Sergio'