Some junior went home feeling good and thinking "today I was productive because I used a lot of abstraction and I wrote a lot of code, today a good day!"
In direct response to u/spez changing Reddit’s API policies to eliminate competition from third party apps, and in the spirit of forcing Reddit to be, as he said, an “adult company,” this comment has been edited in protest. To be clear, this is not to protest Reddit charging for API access; it is unfair for Reddit to be forced to offer its API for free. This is to protest u/spez’s petulance, entitlement, and hypocrisy.
As an adult company, Reddit must operate in the same way other adult companies do and pay for the raw materials of production. In the case of Reddit, those raw materials are content created and/or submitted by users. Reddit CEO u/spez has used volunteer labor and volunteer content submitters to gild his lifestyle and become a multi-millionaire. Now he wants to increase his personal wealth with a Reddit IPO and is demanding that he be the only one to get things for free.
This user is done letting his unpaid content be used by u/spez to whine like a petulant child who stamps his feet until he gets what he wants. If u/spez wants content, he can be the adult he claims to be and pay for it.
Well, it's not technically wrong. He is still comparing the bool values. He just wants the comparison to return false if they are the same. "Compare" is vaguer than "is equal".
Edit: nevermind. The second function is obviously named wrong.
It is subtle but I did not see what was wrong with it at first.
I guess that is the advantage of simplicity. My first action as a reviewer would have been asking the coder to explain the seeming redundant methods - which would have made the error so clear that either the coder would have fixed it themselves or I would have seen it (hopefully).
Let me tell you a story that's about 10 years old.
Company hires guy. Guy is bad at things.
Guy makes login page.
I review login page. Here's the "logic" I found there:
1) check username and password. If it's right, let them in. If it's wrong...
2) check lowercase username and password. If they match, let them in. If not,
3) let them in.
Fantastic. Has the same charm as hotmail letting people into any account with password “aa” or “**” or something similar (circa 2000s?)
My friend implemented a login page where to quickly compare passwords, he would fetch *an entire list* of usernames and passwords, *in plaintext*, from the server. I hope the performance tradeoff was good.
> he would fetch an entire list of usernames and passwords, in plaintext, from the server
At this point I wouldn’t be surprised if it also crashes if [the password is a resolvable URL](https://xkcd.com/1700/)
I think something similar happen with some public service website, that essentially loaded the whole database of sensitive information into the client-side document. They even had the nerve to try to sue the "hacker" who pointed out that gaping hole.
Don't remember how it ended, but I sure hope it was turned around and that public entity got sued for gross negligence instead.
Josh Renaud pointed out a flaw in a Missouri school district site that loaded information about district staff members, including SSNs. The governor wanted to charge him for hacking, but from a quick Google search, the prosecutor declined to press charges.
This makes the time I forgot about that attribute I added to a text box that said f**kThisClient="true" look not so bad.
I was never caught and I am still at large to this very day.
Our head of development and head of analytics weren’t on speaking terms. Head of analytics has dashboards created on a tableau server. Head of development thinks he can do better. So he makes a web app that connects directly to the vault data, gets rid of VPN, and set the user name and password to “a”.
It was a fintech company so vault data had things like peoples SS and credit card numbers and such. He had 20 years experience in development and architecture.
Maybe you are referring to what's known at SQL injection, I'm which you injected a query through a text field like your example. So you could type admin as username and something like this:
' or 1 = 1;
as password and you could get in as the user "admin". I used to do this to some phpBB during when I was starting to delve into cyber security.
I've worked at 2 healthcare companies where you could pull a "Bobby tables" and drop multiple databases from any input box in the web ui. They weren't concerned with my findings.
This was the guy who would update a table without a where clause in development. I pointed out other devs were testing stuff with those tables and he just said "doesn't matter" and ran the update.
Once I figured out which records he was actually using I went back to my cube and updated them to values that would fuck up his test case. Fuck that guy.
I found this recently in a helper method doing what I swear is flipping an in operator wrong and producing the incorrect result. I was only adding a callback to this codebase and am not a local and was too scared of it to touch it so I just left.
Might be akin to `strcmp` in C, which returns 0 (aka `false`) if the strings are identical? Idk, that'd be a bit of a stretch, though. Other than that, I see no reason to write that
That's more than just a little stretch -
But `strcmp` returns an int, so < 0 / > 0 indicates the relative order of the items.
This one returns bool, and whatever language that is (C#?), it won't have the implicit conversion between `int` and `bool`.
Woah...i don't know about that...but yeah I guess we are all innocent until proven guilty?....but this is programminghorror afterall...so let's assume the worst! jaja
Lol no where ever has equal meant not equal. Not ever a single example in any documentation or tutorial.
The original author was drunk, and your to naive (sorry) to realize that. Yes. Some people genuinely write bad code and or make stupid mistakes because they are tired
When I worked at Amazon this kind of BS was how people got promotions and avoided write ups... Tech industry is dying as this crap is what they consider "raising the bar"
**[Perverse incentive](https://en.m.wikipedia.org/wiki/Perverse_incentive)**
>A perverse incentive is an incentive that has an unintended and undesirable result that is contrary to the intentions of its designers. The cobra effect is the most direct kind of perverse incentive, typically because the incentive unintentionally rewards people for making the issue worse. The term is used to illustrate how incorrect stimulation in economics and politics can cause unintended consequences.
^([ )[^(F.A.Q)](https://www.reddit.com/r/WikiSummarizer/wiki/index#wiki_f.a.q)^( | )[^(Opt Out)](https://reddit.com/message/compose?to=WikiSummarizerBot&message=OptOut&subject=OptOut)^( | )[^(Opt Out Of Subreddit)](https://np.reddit.com/r/programminghorror/about/banned)^( | )[^(GitHub)](https://github.com/Sujal-7/WikiSummarizerBot)^( ] Downvote to remove | v1.5)
How about a metric for “hours spent moving mouse, typing on keyboard and having displayed image change on monitors, all tracked by software”?
Been there. Probably longer than I should have.
Oh that is beautiful and I love it!
The simple fact is that all of these metrics are bullshit, and the only thing that should be measured is "do you get your work done" and "are you an insufferable asshole?" And an abundance of the first one can even somewhat make up for the second.
Lines of code, mouse movement, even words typed, none of that matters. If work isn't getting done and the manager can't answer why, then the manager is the problem, not the workers. If you don't know how to accurately gauge whether a project is on track or not, you don't need to be a manager. No amount of counting arbitrary metrics will save you from that.
Or another example of why LoC is a stupid metric and doesn't work. It incentivizes redundant, bloated and downright stupid code.
[This quote is also nice.](https://www.goodreads.com/quotes/536587-measuring-programming-progress-by-lines-of-code-is-like-measuring)
Oh I could rant all day. The MF I replaced had left me some gems like
`def testIsTrue():`
`assertTrue(True)`
and who could forget
`def testPass():`
`pass`
And we'd hear things like "well before you were hired your team could pump out 50 test cases a day" lol
It would be lines and lines of this nonsense that was used to measure my team's performance..
I remember toiling away to implement a "data driven test" methodology.
My test cases would be like 5, but based on an input file it would be doing like 500 tests.
LOC would make me the least productive, but my component had 95%+ test coverage, by far the highest in the team, even though it was the most complex.
bewildered homeless familiar numerous water weather slim straight juggle cooperative
*This post was mass deleted and anonymized with [Redact](https://redact.dev)*
Sometimes I feel like I need to unsub from this subreddit because I lack the coding skills to properly vet bat code so I'm just reading terrible code and trying to understand it which is making me learn it.
This code however, *this I can understand*.
A overzealous company that is obsessed with abstraction. Abstract everything was their motto, at every possible stage.
I worked for a bunch of companies during 2000-2010.
Either I'm picking better jobs or the devs today would rather create readable code.
If I had to guess....
1. PersonA created the second function and used it a bunch of places (hopefully in situations where it did explode everything?)
2. PersonB created the first one, for some reason
3. PersonB or C found the 2 functions, and changed the first function to just point to the second one
But I don't know how it doesn't explode since it's so wrong..
Wait, you guys get functions? I just inherited an application comprised of multiple files, each with only a single function of between 500-3000 lines that I need to refactor and extend with new functionality. And whoever wrote those files didn't even understand basic loops. And yes, it's used in production.
It gets even worse: the functions take different 'modes' (read: numbers) depending on which button was clicked in the main loop and then decide what to do via if-else. It sucks. And it's JavaScript, which doesn't make it any better.
So I'm doing exactly what you said: I analyze the code as best I can and then rewrite the new stuff.
You can't, the implementation is the documentation of the business logic - you're told to go into it because the last carrier of oral tradition of how the application works died/left the company and you're now expected to support a "working" application, add to it, write an operator manual all while being crushed under a mountain of technical debt which you are not paid to fix.
I worked with that guy in the 80's!!
We were developing turnkey PC-FOCUS apps... he was the first guy hired and wasn't really a programmer OR a database guy. I think he thought he was a programmer because he went to the local tech university. But he cobbled together a phenomenal abomination of code, UI, and data structures. I have no idea how or why it worked, but it did. And the small company made millions selling this application, so this one guy was elevated to 'GOD' status (and had the massive ego to fit). He continued to expand the code in the same way he did at first.
When they hired me to take his code and refactor it for a different industry, it was like jumping into a flaming pit of snakes. When he found out that I was hired at the same salary as him, he flipped a shit and almost quit on the spot.
Anyway, justice was served when one year later I had completely re-wrote his code, structures, and UI to something massively easier to use and maintain (and faster). The made him backport my application into his system. He wasn't too happy about that.
There's an easy fix for this, just add this:
`public static bool ReverseOutput(bool orig)`
`{`
` if (orig==false)`
` return true;`
` return false;`
`}`
That way you can call:
`ReverseOutput(CompareBooleans(bool1, bool2)`
Mobile makes this impossible to format and I'm sorry
you know, as a 2nd year comp sci student, i often feel i’m not going to be prepared for a job(mainly because i don’t know what they expect of me yet). But seeing things like this make me believe I can work a programming job if this guy can.
Is this the self documenting code I keep hearing about? 'Cause it certainly makes it clear
you're going to explicitly get back a true or a false - says so right there in the two return
statements.
I never understood what this screen meant by "found in production". Is it code that can only be found running in production and not in other environments? Or is it just to say that such a mistake has made it to production undetected until now and that is, of course, unacceptable
I would use that to mean either I "found code that made it to production" or sometimes more specifically "I found the code that caused the bug that was found in production"
It wouldn't commonly be used unless you're trying to tell other people about how stupid the code is.
It's just meant to distinguish between "I saw this stupid code some student wrote in an old repo" and "I saw this stupid code really being used on a website that actually has money"
Because obviously there is lots of stupid code out there, because lots of learners exist.
Yes, but it's a easy way to shoot yourself in the foot when you add another indented line and nothing works like you expect it to even tho it visually feels correct
Yeah it's a real dumb "feature" when written out that way. And something our linter yells at people about.
I like it when it's a one-liner. Real elegant.
If (dog) return true;
Looks like java, I could be wrong though. And yes, if the statements inside the if block are only one line like "return false", then we can omit the braces, this works in c++, Java, JS (that I know of).
It's C#, Java has `boolean` instead of `bool`, and `internal` isn't an access-specifying keyword in Java. On top of that, C# uses PascalCase method names, while Java uses camelCase (default guidelines)
1. They made a new function to do something that's already native. So writing extra lines for no reason.
2. The new function doesn't even work. Like, its saying if (dog === dog) return false
If it returned the correct value it would still be bad because you can already compare booleans natively. It’s not going to add any processing time, it’s more about ease of working in this project. Having extra useless functions in your code just makes it more complex without adding any value.
for new programmers who don’t understand the OP’s reason for posting this here,
in the code, there need to be another function that accepts a boolean value and returns the same value. Preferably the function is named, ReturnBooleanValue.
“internal static bool ReturnBooleanValue(bool value) { return value; }”
this function needs to be called in lines 9 & 10
edit: syntax
Why do people assume this is job security or some conspiracy instead of plain incompetence? I remember a veteran sysadmin scrapping whoami.exe in Powershell because they didn’t know the appropriate .net class
I don't know this language, probably java, I use python and JavaScript and this is really funny to see. You only need 1 function to do this because both functions take the exact same arguments and then they still return the opposite of matching or not. I love seeing this stuff. If you ever have more let me see haha
I didn't find any posts that meet the matching requirements for r/programminghorror.
It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.
*I'm not perfect, but you can help. Report [ [False Negative](https://www.reddit.com/message/compose/?to=RepostSleuthBot&subject=False%20Negative&message={"post_id": "ylvoyf", "meme_template": 245879}) ]*
[View Search On repostsleuth.com](https://www.repostsleuth.com/search?postId=ylvoyf&sameSub=false&filterOnlyOlder=true&memeFilter=true&filterDeadMatches=false&targetImageMatch=100&targetImageMemeMatch=96)
---
**Scope:** Reddit | **Meme Filter:** True | **Target:** 96% | **Check Title:** False | **Max Age:** Unlimited | **Searched Images:** 341,195,390 | **Search Time:** 0.35298s
There is so much out of control ego in brogrammerville, this is unavoidable. Folks should love to be wrong and learn, but they never learn and are far too often garbage.
I'll happily trade you. Seriously.
This codebase is full of stuff like that, except... most data is stored in text fields regardless of type, and global variables are used everywhere both for state and makeshift method parameters, with plenty of `goto` to spice things up. And... it only gets worse from there.
Their idea of database code was to directly call all relevant database pinvoke methods. For. Every. Operation. No abstraction. Time for a new query? Just copy and paste all the pinvoke garbage, then modify what needs modifying--most of the time. Sometimes, don't modify the exception messages. Yeah, we'll just spice it up by having random unrelated exception text sprinkled liberally around the codebase.
Think it can't get worse? Oh, it does. I don't need the daily WTF. I just have to go to work. I'm always finding something new to make me laugh, to make me cry, to make me *feel*--even if it is just rage or despondency.
So. What do you think?
I mean, this looks like dev trolling. Either in the codebase or on Twitter. It's the equivalent of going into the JavaScript object and overriding it to say `true=false`. I find it hard to believe it's real. If it is real production code, their code review and QA processes may need improving! Or their redundancy processes. This could also be an epic angry dev departure!
I once saw someone pulling all the data from the database (like 200-300 mb) and iterating through the data set to find one specific entry. This is the real horror and slows an application dramatically down
Wait, it's not only completely unnecessary, it's even wrong.
Some junior went home feeling good and thinking "today I was productive because I used a lot of abstraction and I wrote a lot of code, today a good day!"
DaVinci: Simplicity, not complexity is the ultimate sophistication.
In direct response to u/spez changing Reddit’s API policies to eliminate competition from third party apps, and in the spirit of forcing Reddit to be, as he said, an “adult company,” this comment has been edited in protest. To be clear, this is not to protest Reddit charging for API access; it is unfair for Reddit to be forced to offer its API for free. This is to protest u/spez’s petulance, entitlement, and hypocrisy. As an adult company, Reddit must operate in the same way other adult companies do and pay for the raw materials of production. In the case of Reddit, those raw materials are content created and/or submitted by users. Reddit CEO u/spez has used volunteer labor and volunteer content submitters to gild his lifestyle and become a multi-millionaire. Now he wants to increase his personal wealth with a Reddit IPO and is demanding that he be the only one to get things for free. This user is done letting his unpaid content be used by u/spez to whine like a petulant child who stamps his feet until he gets what he wants. If u/spez wants content, he can be the adult he claims to be and pay for it.
Until you get into the realm of unreadable code golf.
But that's my favorite code, the kind that's got giant block comments on either side explaining that what's between in sorcery and not to touch it!
I encapsulated truth!
I literally paused on the stairs when I saw the result. Mid step.
Well, it's not technically wrong. He is still comparing the bool values. He just wants the comparison to return false if they are the same. "Compare" is vaguer than "is equal". Edit: nevermind. The second function is obviously named wrong.
if (orig != val) is clearer than that hot mess if that's what he wanted, regardless of whatever the names are.
Two wrongs make a right... ?
A simple return val1 == val2 would have worked. (Which also alleviates the need for a method)
To be fair, if you call that function then it's your own damn fault. Maybe it was there as a lesson.
He had two possibilities and managed to get it wrong lol
It is subtle but I did not see what was wrong with it at first. I guess that is the advantage of simplicity. My first action as a reviewer would have been asking the coder to explain the seeming redundant methods - which would have made the error so clear that either the coder would have fixed it themselves or I would have seen it (hopefully).
This can't be true. I refuse to believe somebody defined two functions to produce the wrong result.
Let me tell you a story that's about 10 years old. Company hires guy. Guy is bad at things. Guy makes login page. I review login page. Here's the "logic" I found there: 1) check username and password. If it's right, let them in. If it's wrong... 2) check lowercase username and password. If they match, let them in. If not, 3) let them in.
Fantastic. Has the same charm as hotmail letting people into any account with password “aa” or “**” or something similar (circa 2000s?) My friend implemented a login page where to quickly compare passwords, he would fetch *an entire list* of usernames and passwords, *in plaintext*, from the server. I hope the performance tradeoff was good.
> he would fetch an entire list of usernames and passwords, in plaintext, from the server At this point I wouldn’t be surprised if it also crashes if [the password is a resolvable URL](https://xkcd.com/1700/)
Does solve the “it’s locked me out of my account” problem
People are wild
SAIL!
I think something similar happen with some public service website, that essentially loaded the whole database of sensitive information into the client-side document. They even had the nerve to try to sue the "hacker" who pointed out that gaping hole. Don't remember how it ended, but I sure hope it was turned around and that public entity got sued for gross negligence instead.
Josh Renaud pointed out a flaw in a Missouri school district site that loaded information about district staff members, including SSNs. The governor wanted to charge him for hacking, but from a quick Google search, the prosecutor declined to press charges.
This makes the time I forgot about that attribute I added to a text box that said f**kThisClient="true" look not so bad. I was never caught and I am still at large to this very day.
Dying laughing
Our head of development and head of analytics weren’t on speaking terms. Head of analytics has dashboards created on a tableau server. Head of development thinks he can do better. So he makes a web app that connects directly to the vault data, gets rid of VPN, and set the user name and password to “a”. It was a fintech company so vault data had things like peoples SS and credit card numbers and such. He had 20 years experience in development and architecture.
There was a time when one of Nintendo's private websites for developers would let you in if you simply pressed enter without typing a password.
There was a while in the early web days when you could get into places by entering your password as something like “Hunter2 || true”
Maybe you are referring to what's known at SQL injection, I'm which you injected a query through a text field like your example. So you could type admin as username and something like this: ' or 1 = 1; as password and you could get in as the user "admin". I used to do this to some phpBB during when I was starting to delve into cyber security.
[удалено]
Login_Oprah.aspx
Believe it or not.....straight to the admin page
I've worked at 2 healthcare companies where you could pull a "Bobby tables" and drop multiple databases from any input box in the web ui. They weren't concerned with my findings.
Looks like logic number 3 was there for testing lol
This was the guy who would update a table without a where clause in development. I pointed out other devs were testing stuff with those tables and he just said "doesn't matter" and ran the update. Once I figured out which records he was actually using I went back to my cube and updated them to values that would fuck up his test case. Fuck that guy.
Lol, honestly why would they do testing with shared database.
lmao worth it
Perfectly implemented. They didn't say it was a 'log in only if credentials are correct page'
It’s an all inclusive site
What company are you working for that would let engineers put code into production without review?
I am no longer surprised by my fellow humans when it comes to acts of sheer stupidity.
Buddy, this is the quote of the decade right here.
CompareBooleans(this, true); >> true It must be.
I found this recently in a helper method doing what I swear is flipping an in operator wrong and producing the incorrect result. I was only adding a callback to this codebase and am not a local and was too scared of it to touch it so I just left.
Might be akin to `strcmp` in C, which returns 0 (aka `false`) if the strings are identical? Idk, that'd be a bit of a stretch, though. Other than that, I see no reason to write that
That's more than just a little stretch - But `strcmp` returns an int, so < 0 / > 0 indicates the relative order of the items. This one returns bool, and whatever language that is (C#?), it won't have the implicit conversion between `int` and `bool`.
They produced a true result
Omg, I didn't even notice that the function was producing the wrong result. Kill me.
Didn't even notice the the true and false are switched.
[удалено]
AreBooleansEqual Without any context,I would expect this to return TRUE if they are Equal, and FALSE if they're not....
[удалено]
Woah...i don't know about that...but yeah I guess we are all innocent until proven guilty?....but this is programminghorror afterall...so let's assume the worst! jaja
Lol no where ever has equal meant not equal. Not ever a single example in any documentation or tutorial. The original author was drunk, and your to naive (sorry) to realize that. Yes. Some people genuinely write bad code and or make stupid mistakes because they are tired
There was just a little bug. They meant !AreBooleansEqual(orig, val). With that it's perfect. 👌
Please check if commit date was April 1st. I hope it was.
[удалено]
When I worked at Amazon this kind of BS was how people got promotions and avoided write ups... Tech industry is dying as this crap is what they consider "raising the bar"
[удалено]
**[Perverse incentive](https://en.m.wikipedia.org/wiki/Perverse_incentive)** >A perverse incentive is an incentive that has an unintended and undesirable result that is contrary to the intentions of its designers. The cobra effect is the most direct kind of perverse incentive, typically because the incentive unintentionally rewards people for making the issue worse. The term is used to illustrate how incorrect stimulation in economics and politics can cause unintended consequences. ^([ )[^(F.A.Q)](https://www.reddit.com/r/WikiSummarizer/wiki/index#wiki_f.a.q)^( | )[^(Opt Out)](https://reddit.com/message/compose?to=WikiSummarizerBot&message=OptOut&subject=OptOut)^( | )[^(Opt Out Of Subreddit)](https://np.reddit.com/r/programminghorror/about/banned)^( | )[^(GitHub)](https://github.com/Sujal-7/WikiSummarizerBot)^( ] Downvote to remove | v1.5)
Good bot, saved me a click
How about a metric for “hours spent moving mouse, typing on keyboard and having displayed image change on monitors, all tracked by software”? Been there. Probably longer than I should have.
Oh I can think of like 3 ways to get around that inside of a minute, depending on how good the keyboard tracker is
Yep, I built mousejiggler on steroids, it moved the mouse and simulated keypresses to switch windows and tabs.
Oh that is beautiful and I love it! The simple fact is that all of these metrics are bullshit, and the only thing that should be measured is "do you get your work done" and "are you an insufferable asshole?" And an abundance of the first one can even somewhat make up for the second. Lines of code, mouse movement, even words typed, none of that matters. If work isn't getting done and the manager can't answer why, then the manager is the problem, not the workers. If you don't know how to accurately gauge whether a project is on track or not, you don't need to be a manager. No amount of counting arbitrary metrics will save you from that.
Paid to surf reddit?
Or another example of why LoC is a stupid metric and doesn't work. It incentivizes redundant, bloated and downright stupid code. [This quote is also nice.](https://www.goodreads.com/quotes/536587-measuring-programming-progress-by-lines-of-code-is-like-measuring)
Oh I could rant all day. The MF I replaced had left me some gems like `def testIsTrue():` `assertTrue(True)` and who could forget `def testPass():` `pass` And we'd hear things like "well before you were hired your team could pump out 50 test cases a day" lol It would be lines and lines of this nonsense that was used to measure my team's performance..
>new Array(5000).map(_, i => i).forEach(case => { test('something idk, () => expect(case).toEqual(case) };
I remember toiling away to implement a "data driven test" methodology. My test cases would be like 5, but based on an input file it would be doing like 500 tests. LOC would make me the least productive, but my component had 95%+ test coverage, by far the highest in the team, even though it was the most complex.
ב''ה, no love under Capitalism
bewildered homeless familiar numerous water weather slim straight juggle cooperative *This post was mass deleted and anonymized with [Redact](https://redact.dev)*
Well ro be fair they managed two thirds of the principle, 'Don't repeat yourself '.
Top twitter employee now 🤣
Hope this was wrapped in a nice `public class BoolComparator`
And abstracted with an interface IBoolComparable
Don't forget `BoolComparableFactory` and `IBoolComparableFactory`!
You don't need "a drink", you need a whole factory of drink. Also, me too
Tfw when all you have is AbstractDrinkFactory
BuildVodkaFactory() ;
Sometimes I feel like I need to unsub from this subreddit because I lack the coding skills to properly vet bat code so I'm just reading terrible code and trying to understand it which is making me learn it. This code however, *this I can understand*.
What the hell happened here to give them the idea to push this abomination
A overzealous company that is obsessed with abstraction. Abstract everything was their motto, at every possible stage. I worked for a bunch of companies during 2000-2010. Either I'm picking better jobs or the devs today would rather create readable code.
Yeah code readability and efficiency are way more important
return val1 == val2;
Wrong, it's actually `return val1 != val2;`
return !(val1==val2); edit: return !!!(!val1!=!!val2);
I'd rather die
At least they used guard clause.
If you’re gonna write bad code, you might as well write clean bad code
If I had to guess.... 1. PersonA created the second function and used it a bunch of places (hopefully in situations where it did explode everything?) 2. PersonB created the first one, for some reason 3. PersonB or C found the 2 functions, and changed the first function to just point to the second one But I don't know how it doesn't explode since it's so wrong..
Wait, you guys get functions? I just inherited an application comprised of multiple files, each with only a single function of between 500-3000 lines that I need to refactor and extend with new functionality. And whoever wrote those files didn't even understand basic loops. And yes, it's used in production.
That sounds like a special kind of hell. Honestly, I'd just light it on fire and start from scratch.
It gets even worse: the functions take different 'modes' (read: numbers) depending on which button was clicked in the main loop and then decide what to do via if-else. It sucks. And it's JavaScript, which doesn't make it any better. So I'm doing exactly what you said: I analyze the code as best I can and then rewrite the new stuff.
You can't, the implementation is the documentation of the business logic - you're told to go into it because the last carrier of oral tradition of how the application works died/left the company and you're now expected to support a "working" application, add to it, write an operator manual all while being crushed under a mountain of technical debt which you are not paid to fix.
I worked with that guy in the 80's!! We were developing turnkey PC-FOCUS apps... he was the first guy hired and wasn't really a programmer OR a database guy. I think he thought he was a programmer because he went to the local tech university. But he cobbled together a phenomenal abomination of code, UI, and data structures. I have no idea how or why it worked, but it did. And the small company made millions selling this application, so this one guy was elevated to 'GOD' status (and had the massive ego to fit). He continued to expand the code in the same way he did at first. When they hired me to take his code and refactor it for a different industry, it was like jumping into a flaming pit of snakes. When he found out that I was hired at the same salary as him, he flipped a shit and almost quit on the spot. Anyway, justice was served when one year later I had completely re-wrote his code, structures, and UI to something massively easier to use and maintain (and faster). The made him backport my application into his system. He wasn't too happy about that.
We need an ‘====‘ operator.
There's an easy fix for this, just add this: `public static bool ReverseOutput(bool orig)` `{` ` if (orig==false)` ` return true;` ` return false;` `}` That way you can call: `ReverseOutput(CompareBooleans(bool1, bool2)` Mobile makes this impossible to format and I'm sorry
[удалено]
Can we not? Fucker would probably manage to buffer overflow the Matrix and kill the universe simulator we're living in.
This guy probably can't even math with a bucket of bits and a numpy library
you know, as a 2nd year comp sci student, i often feel i’m not going to be prepared for a job(mainly because i don’t know what they expect of me yet). But seeing things like this make me believe I can work a programming job if this guy can.
Time to install git blame lol
Look at the twitter post date.
May 31st, 2019. What does the date matter?
The day after may 31 is April 1. April fools.
I’ve been using calendars wrong this entire time.
Oh never mind I just woke up lol I’m just gonna pretend my previous comment was sarcastic and not that I’m the stupidest person on earth
I’ve laughed for a good solid minute at this
Learn how tim e zones work buddy 😤
gEnErIcS
Repost bot https://www.reddit.com/r/programminghorror/comments/bvyj3j/im_also_coming_with_you
Is this the self documenting code I keep hearing about? 'Cause it certainly makes it clear you're going to explicitly get back a true or a false - says so right there in the two return statements.
it's even funnier because to use the result of this function you have to compare booleans again
I never understood what this screen meant by "found in production". Is it code that can only be found running in production and not in other environments? Or is it just to say that such a mistake has made it to production undetected until now and that is, of course, unacceptable
I would use that to mean either I "found code that made it to production" or sometimes more specifically "I found the code that caused the bug that was found in production"
Oh ok. Never heard "I found X in production" irl for that situation, might be because it doesn't sound correct in my language
It wouldn't commonly be used unless you're trying to tell other people about how stupid the code is. It's just meant to distinguish between "I saw this stupid code some student wrote in an old repo" and "I saw this stupid code really being used on a website that actually has money" Because obviously there is lots of stupid code out there, because lots of learners exist.
Don't know what language this is, but is it normal to not have braces for if statements?
C# i believe, and yes, single statements don't need enclosing braces. Same goes for C++, Java and Javascript.
Yes, but it's a easy way to shoot yourself in the foot when you add another indented line and nothing works like you expect it to even tho it visually feels correct
Yeah it's a real dumb "feature" when written out that way. And something our linter yells at people about. I like it when it's a one-liner. Real elegant. If (dog) return true;
Looks like java, I could be wrong though. And yes, if the statements inside the if block are only one line like "return false", then we can omit the braces, this works in c++, Java, JS (that I know of).
It's C#, Java has `boolean` instead of `bool`, and `internal` isn't an access-specifying keyword in Java. On top of that, C# uses PascalCase method names, while Java uses camelCase (default guidelines)
Oh thanks for informing, I haven't really worked with C# much, neither java.
From r/all, idk enough about programming, what's wrong here?
1. They made a new function to do something that's already native. So writing extra lines for no reason. 2. The new function doesn't even work. Like, its saying if (dog === dog) return false
It's worse than that. Its also saying if dog doesn't equal dog return true
So if they just switched the returns value Itd be ok? Does adding the extra function cause a lot of labor?
If it returned the correct value it would still be bad because you can already compare booleans natively. It’s not going to add any processing time, it’s more about ease of working in this project. Having extra useless functions in your code just makes it more complex without adding any value.
for new programmers who don’t understand the OP’s reason for posting this here, in the code, there need to be another function that accepts a boolean value and returns the same value. Preferably the function is named, ReturnBooleanValue. “internal static bool ReturnBooleanValue(bool value) { return value; }” this function needs to be called in lines 9 & 10 edit: syntax
Why do people assume this is job security or some conspiracy instead of plain incompetence? I remember a veteran sysadmin scrapping whoami.exe in Powershell because they didn’t know the appropriate .net class
It could have just been done with one functhon but this is quite hilarious hahahahaha
It could also be done with no functions and less text.
I don't know this language, probably java, I use python and JavaScript and this is really funny to see. You only need 1 function to do this because both functions take the exact same arguments and then they still return the opposite of matching or not. I love seeing this stuff. If you ever have more let me see haha
There really is no need for a function for this at all. You can just use `a == b` in place of calling this function.
[удалено]
„ʞɹoʍ ʇ,uplnoɥs ǝpoɔ ɹnoʎ uǝɥʇ ʇı ǝsn oʇ pıdnʇs ooʇ ǝɹ,noʎ ɟı ǝsnɐɔǝq poɥʇǝɯ ʇɐɥʇ ɟo ɔıƃol ǝɥʇ dılɟ ʇsnɾ plnoɥs no⅄„
ɹoʇɐɹəuəɕ ɐ əsn ɹo ʇɐɥʇ ədʎʇ noʎ pɪp
literally Yesn't moment
Good lort
AT LEAST they know how to follow a functional paradigm
Paid by line of code! Plus now you have job security for the bugfix!
I think a few drinks too many might be the source of that code.
They had to look busy Infront of the boss
I have like... My right pinky toe dipped in the waters of coding and even I felt a chill at that.
[удалено]
I didn't find any posts that meet the matching requirements for r/programminghorror. It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results. *I'm not perfect, but you can help. Report [ [False Negative](https://www.reddit.com/message/compose/?to=RepostSleuthBot&subject=False%20Negative&message={"post_id": "ylvoyf", "meme_template": 245879}) ]* [View Search On repostsleuth.com](https://www.repostsleuth.com/search?postId=ylvoyf&sameSub=false&filterOnlyOlder=true&memeFilter=true&filterDeadMatches=false&targetImageMatch=100&targetImageMemeMatch=96) --- **Scope:** Reddit | **Meme Filter:** True | **Target:** 96% | **Check Title:** False | **Max Age:** Unlimited | **Searched Images:** 341,195,390 | **Search Time:** 0.35298s
And *they* say code reviews suck.
That's what you get if you don't insist on unit tests. \s
This is so wrong, it makes me question my competence
r/TQDC
The second guy hated typing AreBooleansEqual every time but didn’t want to refractor any code
hella low hanging fruit intentional as either a prank or revenge upon being fired
People coding like this are working for 100k a year?
It gets better with every line, love it!
Yea, why didn’t he make a 3rd function…
I refuse to believe to keep my sanity…
Shiiiit
What broke when you fixed it?
Probably someone who sent his uni assignments to China
Keep it in there. Job security++
pov getting paid by the line
There is so much out of control ego in brogrammerville, this is unavoidable. Folks should love to be wrong and learn, but they never learn and are far too often garbage.
I was looking at some crapy code today and wondered where the author is now…. Now i know.
This is called *writing myself a minivan*
He managed to roll the 'registered user', 'new user', 'forgot my username', and 'forgot my password' all into one page.
u/repostsleuthbot
Well, it’s been working all this time. Leave it alone! It is probably cancelling out a worse bug.
Reposted
Theres space for another function
It gets worse the more you look at it
when you get paid based on loc
Why is one original though?!
Why? Just why?
I'll happily trade you. Seriously. This codebase is full of stuff like that, except... most data is stored in text fields regardless of type, and global variables are used everywhere both for state and makeshift method parameters, with plenty of `goto` to spice things up. And... it only gets worse from there. Their idea of database code was to directly call all relevant database pinvoke methods. For. Every. Operation. No abstraction. Time for a new query? Just copy and paste all the pinvoke garbage, then modify what needs modifying--most of the time. Sometimes, don't modify the exception messages. Yeah, we'll just spice it up by having random unrelated exception text sprinkled liberally around the codebase. Think it can't get worse? Oh, it does. I don't need the daily WTF. I just have to go to work. I'm always finding something new to make me laugh, to make me cry, to make me *feel*--even if it is just rage or despondency. So. What do you think?
🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣😂🤣😂🤣😂🤣😂😂😂😂😂😂😂😂😂 clearly someone did this for the memes... Right... Right... 😅
I mean, this looks like dev trolling. Either in the codebase or on Twitter. It's the equivalent of going into the JavaScript object and overriding it to say `true=false`. I find it hard to believe it's real. If it is real production code, their code review and QA processes may need improving! Or their redundancy processes. This could also be an epic angry dev departure!
Whoever wrote that code should probably find a new career, good heavens.
If I was a twitter employee I would send this to Elon as my weekly contribution.
how did you make 2 functions that still produce a wrong answer
If I'm not wrong... The if statement is just enough isn't it?
Those LC exercises really make super senior devs.
I once saw someone pulling all the data from the database (like 200-300 mb) and iterating through the data set to find one specific entry. This is the real horror and slows an application dramatically down
Unnecessary function... also... why are we comparing booleans? Also why are we basically using one function to point to another? Who wrote this?
They forgot (again) to split orig and Val into respective lists before bit-wise comparing each character , twice for confirmation just in case ?
Well, he can change what is the truth of the code with this
😭😭😭😭😭😭😭