I knew there had to be curly brackets missing somewhere because my IDE wasn't matching the last ones to any pair, but I couldn't for the life of me find where I'd missed them. Thanks for the pointer, fixed now!
I didn't. Section 3, here explains why OCR is bad for code posts, and here's our OCR bot's attempt at this post - we use ocr.space's API, which is one of the best in the world.
What clearly is happening here is they have multiple places where callback could be called multiple times. So this prevents callback from being invoked twice.
There is an extension for it, if you're really interested I could look up the name of it. there's no need for it though, just hit prntscrn and paste your image to your fav image editor and crop.
Why bother having the comments if they are only going to say what a variable is, among other things. That’s what variable names are for.
Comments shouldn’t explain how, they should explain what. For example what a function is, and typical return values.
And if you must include comments that are lower down then that, then it should be on structures, ie loops, callbacks, etc, having a comment that explains what a single line does defeats the purpose of comments imo.
Comments should explain why, and they should only explain why if that isn't obvious from looking at that piece of code for a couple of seconds, and if more than, say, 10% of your code requires such an explanation then you need to improve on naming, architecture etc.
I actually ran into a less ridiculous but similarly formatted commenting Style at work not long ago. I had never seen it before. Is this style of commenting actually practiced? At the time I thought it might have been copy pasted generated code of some sort, but now I'm not so sure
It's been awhile since I've seen a good callback hell example like this. We've had promises for almost a decade now, so I imagine most people on this sub don't remember how bad it could get.
This site is still up and is a pretty good insight into the prevailing style at a time when async functions were still "a proposed feature".
Edit: The irony of this is that they're already passing anonymous async functions to DB at the top, and async functions return promises. So they do have other code in their codebase that's handling promises.
Out of curiosity what program do people use to get these pretty looking windows? it doesn’t have a title bar or anything it’s just text and what looks like some sort of mac generic unix like window. Am i stupid or is it something special
Well, can you at least offer an explination? My experience with linux is entirely command line based (because linux with a gui is for posers) and i’m curious as to what program people use to get these rlly pretty photos of code
I worked at a place where the original dev believed in security through obscurity wholeheartedly. For a while he had convinced everyone that it’s the way to go. There was so much dumb stuff in the code, it was a nightmare to do anything with. Even though the system was “rewritten” after he left it was basically just the same code but in a different language, and with an additional layer of cargo cult programming on top since no one knew what the original did or fully understood his obfuscated variable naming. I eventually became the sole maintainer of the system for a while. I did eventually descend into the pits of madness enough that I figured out how to bend any part of the code to my will. The code had become second nature to me and it seemed so natural and plain. No longer could it hold back its secrets from me. That’s when I knew I probably needed to switch to another codebase, so I changed jobs
90
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 09 '23 edited Feb 10 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
52
u/PooSham Feb 10 '23
Nevermind the insane nesting and ridiculous comments. Why is the database connected to twice in a row???
118
u/Nasatyau Feb 09 '23
Sometimes I think about unsubbing from r/badcode & r/programminghorror, but then something like this drops into my feed 🤌
13
u/f11y11 Feb 09 '23
comment porn
19
u/Teja1821 Feb 09 '23
How do you export code like this image? Looks sick
13
u/[deleted] Feb 09 '23
yep. that's bad code
12
u/Nick433333 Feb 09 '23
Why bother having the comments if they are only going to say what a variable is, among other things. That’s what variable names are for.
Comments shouldn’t explain how, they should explain what. For example what a function is, and typical return values.
And if you must include comments that are lower down then that, then it should be on structures, ie loops, callbacks, etc, having a comment that explains what a single line does defeats the purpose of comments imo.
4
u/Cybasura Feb 09 '23
The ultimate security through obscurity, obfuscation at its fines
4
u/[deleted] Feb 10 '23
My goodness. This is some of the worst code that I’ve seen in a while, and I see a lot of bad code
3
u/Bisquizzle Feb 09 '23
there's a lot to unpack here... I'll just take your word for it :P
3
u/[deleted] Feb 10 '23
And formatting
2
u/artnos Feb 10 '23
What the hell is going on, why does he call the database twice, is this student work?
2
u/typehyDro Feb 10 '23
Sooo many useless comments… and is that back to back connections to the same DB…
2
u/seanyover9000 Feb 10 '23
Oh my god what the hell is this
2
u/rocketengineer95 Feb 09 '23
My never nesting self wants to cry.
1
u/Cervarl_ Feb 09 '23
firebase.autenticateWithCredentials(emails, pass);
1
u/brandywine_whistler Feb 09 '23
absolutely hilarious. Let me guess, all seniors were out sick the day this got merged. a good reason for code reviews.
1
u/hansmac123 Feb 09 '23
I thought it was a book..
1
u/Fury9999 Feb 10 '23
I actually ran into a less ridiculous but similarly formatted commenting Style at work not long ago. I had never seen it before. Is this style of commenting actually practiced? At the time I thought it might have been copy pasted generated code of some sort, but now I'm not so sure
1
u/[deleted] Feb 10 '23
When I saw the thumbnail I thought, "well at least it's well-commented." Then I started reading it...
1
u/jcslickt Feb 10 '23
I like to see the unit tests.
1
u/manafount Feb 10 '23 edited Feb 10 '23
It's been awhile since I've seen a good callback hell example like this. We've had promises for almost a decade now, so I imagine most people on this sub don't remember how bad it could get.
This site is still up and is a pretty good insight into the prevailing style at a time when async functions were still "a proposed feature".
Edit: The irony of this is that they're already passing anonymous async functions to DB at the top, and async functions return promises. So they do have other code in their codebase that's handling promises.
1
u/satansxlittlexhelper Feb 10 '23
Wait. WTF is ‘r’?
1
u/kristallnachte Feb 10 '23
Jesus, how is that one function?
Like...idk if I could write a function that takes that long to serialize a user...
1
u/redheness Feb 10 '23
I bet he's from the people who say "Fuck ORMs, I prefer having full control over the SQL requests I write"
1
u/moontr3 Feb 10 '23
why don’t you just if (input == password) { return true; } return false;
1
u/zickige_zicke Feb 10 '23
Callback hell
1
u/[deleted] Feb 10 '23
Tell me it's not a single function
1
u/Overcooked-Cabbage Feb 10 '23
(I know the if block looks copy pasted but still it's funny)
1
u/prisonbird Feb 10 '23
how do you make that screenshot ?
1
u/toxic_egg Feb 10 '23
even the blank line between const 2 & 3 is annoying
1
u/ThunderAvenger Feb 12 '23
Looks like that pride flag at this point
1
u/Hamburger317 Feb 14 '23
There’s more useless comments here than the average programming tutorial
1
u/SubatomicPlatypodes Feb 09 '23 edited Feb 10 '23
Out of curiosity what program do people use to get these pretty looking windows? it doesn’t have a title bar or anything it’s just text and what looks like some sort of
macgeneric unix like window. Am i stupid or is it something special0
u/[deleted] Feb 09 '23
For what it's worth, it's well document!
0
u/Impossible_Average_1 Feb 09 '23
At least the code is commented, so you can also read it as pseudo code...
0
u/[deleted] Feb 09 '23
[deleted] — view deleted comment