this post was submitted on 28 Oct 2024
505 points (98.3% liked)

Programming Humor

2612 readers
10 users here now

Related Communities [email protected] [email protected] [email protected] [email protected]

Other Programming Communities [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

founded 1 year ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 107 points 1 week ago (2 children)

Wait areBooleanEqual returns false when they are equal?

[–] [email protected] 79 points 1 week ago (1 children)
load more comments (1 replies)
[–] [email protected] 10 points 1 week ago (2 children)

That's not even the worst part. What the fuck does a function named Compare_anything do? Does it return anything? It sounds like nothing but a side effect.

[–] [email protected] 11 points 1 week ago

Usually comparison functions are supposed to return an integer and are usually useful for sorting. However this one returns a bool so it's both useless and terribly named.

[–] [email protected] 7 points 1 week ago (1 children)

The unnecessary and confusing functions are horrible, yes, but I'd still say that the fact that they're wrong is the "worst" part.

load more comments (1 replies)
[–] [email protected] 85 points 1 week ago (2 children)

Don’t forget the invocation

if (CompareBooleans(a, b) == true)
[–] [email protected] 59 points 1 week ago (2 children)

if (CompareBooleans(CompareBooleans(a, b), true))

[–] [email protected] 9 points 1 week ago (1 children)

I don't like this thread anymore :(

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 18 points 1 week ago

elseif(CompareBooleans(b,a) != false)

[–] [email protected] 57 points 1 week ago (1 children)

Management: Gee whiz, we really have no idea how to gauge productivity to decide who gets promoted. We could manage. Or, better, we could just have someone write a script that pulls info from git on how many lines of code each person has written.

Programmers:

[–] [email protected] 22 points 1 week ago (4 children)

I promote based on lines of code removed.

[–] [email protected] 27 points 1 week ago (4 children)

I quit based on idiotic metrics

load more comments (4 replies)
[–] [email protected] 5 points 1 week ago (1 children)

Which is all the easier to do when you start off with a higher number...

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 53 points 1 week ago (1 children)

There’s no way, that’s so insane it has layers.

[–] [email protected] 18 points 1 week ago

At first, I thought the shitty methods were the joke 😱😱😱

[–] [email protected] 51 points 1 week ago (1 children)

This is code after working 16 hours

[–] [email protected] 11 points 1 week ago (1 children)

I'd give my right hand this is a code review problem. Someone extracted a method returning true false. Then an intern came along and was told to refactor. They saw a lot of comparisons and "extracted" them.

[–] nitefox 7 points 1 week ago (1 children)

My coworker made an array of book to express a status. This is no doing of an intern but a much eviler force at play.

load more comments (1 replies)
[–] [email protected] 34 points 1 week ago (1 children)

"You aren't writing enough lines of code!" - Management

[–] [email protected] 8 points 1 week ago

My boss's boss, a former Ops manager who liked to keep track of system stats, once asked her why the CPU usage on the dev box had decreased that month. Weren't the devs doing any work?

[–] Grandwolf319 30 points 1 week ago

Two wrongs don’t make a right, but sometimes in programming, two bugs can cancel each other out.

Whoever wrote this is more than capable of using it incorrectly.

[–] [email protected] 21 points 1 week ago

Is this part of Elons "How many lines of choice have you written?" interview?

[–] [email protected] 21 points 1 week ago* (last edited 1 week ago) (6 children)

Those are rookie lines of code numbers right there.
I would have done it without the ==

internal static bool AreBooleansEqual(bool orig, bool val)
{
    if(orig) 
    {
        if(val)
            return false
        return true
    }
    if(val)
        return true 
    return false
}

Don't know why their code returns false when they are equal but I'm not going to dig through old code to refactor to use true instead of false.

[–] [email protected] 9 points 1 week ago (1 children)

you can also use XOR operation

return (X || Y) && !(X && Y)
load more comments (1 replies)
load more comments (5 replies)
[–] [email protected] 18 points 1 week ago (11 children)
[–] [email protected] 7 points 1 week ago

Weekly downloads: 152,124

load more comments (10 replies)
[–] [email protected] 18 points 1 week ago (1 children)

You can tell they're amateurs. It's not obfuscated enough. They won't be able to keep their job.

[–] [email protected] 19 points 1 week ago (1 children)

They clearly need an abstract boolean comparison factory.

[–] [email protected] 21 points 1 week ago* (last edited 1 week ago) (1 children)
var CompareBooleans = new ComparatorFactory().BooleanComparator(new BooleanComparisonByEqualityPolicy());
if (CompareBooleans(a, b) == true) {
     System.Out.PrintLn("Sames!!!");
}

...

But now that I've written this, it's C#, so it's missing dependency injection.

[–] [email protected] 6 points 1 week ago

I can imagine Uncle Bob be proud of this Clean Code (TM)

[–] [email protected] 18 points 1 week ago (1 children)

My guess to why there’s two functions is because it was originally only internal, and the programmer realized they needed public as well, but changing internal to public is too scary so they created a new method instead.

load more comments (1 replies)
[–] [email protected] 17 points 1 week ago (1 children)

"We need to obfuscate our code to prevent reverse engineering"

The obfuscation in question:

[–] [email protected] 6 points 1 week ago (1 children)

We affectionately called it "subscurity" on the FE team.

When our BE apis would not give us any information why something failed, nor would they give us access to their logs. Complete black box of undocumented doodoo, and they would proudly say "security through obscurity" every time we asked why they couldn't make improvements to usability.

load more comments (1 replies)
[–] zarkanian 16 points 1 week ago

If this were a Node module, I wouldn't even be surprised.

[–] [email protected] 14 points 1 week ago (1 children)

Clearly it should be return orig == val

Duh

[–] [email protected] 34 points 1 week ago (1 children)

To match the current behavior it should be orig != val

load more comments (1 replies)
[–] [email protected] 12 points 1 week ago

I'm a bit disappointed there isn't a call to GetBooleanValue in there

[–] [email protected] 9 points 1 week ago

!NOT

Who's there?

!!Naughty Knots

[–] [email protected] 8 points 1 week ago

Where are the unit tests?

[–] [email protected] 8 points 1 week ago

But how do you test for FILE_NOT_FOUND?

[–] [email protected] 7 points 1 week ago

Straight from the famous book "Making LOCs for Dummies"

[–] [email protected] 6 points 1 week ago (1 children)

I misread it as CompareBolians. No more Star Trek memes for me today.

[–] [email protected] 5 points 1 week ago

Many Bolians died bringing us this information.

[–] [email protected] 6 points 1 week ago
[–] [email protected] 5 points 1 week ago

Thanks I hate it

[–] [email protected] 5 points 1 week ago (3 children)

WTAF? Is this written by a hallucinating AI?

load more comments (3 replies)
load more comments
view more: next ›