745
phiter
2y

I wouldn't believe it hadn't I seen this with my own eyes.

Comments
  • 71
  • 6
    what language is it?
    how is it possible refer to method without defining classname?
  • 20
    @norman70688 it's c#
    Those two static methods are either called within the same class they're defined or there's a "using static ClassName" (c# 6 feature)
  • 42
    Along with 13 and 11 references to those functions.

    You ever get so sick of working with shit code, you decide to go full Stockholm syndrome and start writing shit code of your own? I've done that. My reasoning is "You must like shit code. Here, have some more shit code".
  • 19
    1024 upvotes, you're welcome!
  • 24
    Abstraction, son!
  • 38
    Its for modularity... just Imagine the work if you ever want to replace true by lets say 42 and you'd have to go through all your code...

    Or maybe the dev plans to change this to a random true/false once he gets fired
  • 5
    @g-m-f bool cannot return null ( atleast you cannot set it to it, it would probably return null in something like this: "bool a;")
  • 23
    Unit testing must be Epic on that project
  • 7
    @No-one in C# I believe that would actually throw a compiler error if you tried to read before assigning it :)
  • 4
    @Jamoyjamie possibly, that was just my guess.
    once i tryed to assign null value to bool - no luck
  • 14
    Make those nonstatic. And extract an interface. Like what if the implementation of returnFalse() changes or needs to be mocked, you know?
  • 32
    @QoolQuy2000 This comment made my day.

    "You must like shit code. Here, have some more shit code" is TOTALLY going into a commit message. And soon.
  • 5
    @norman70688 in C# u can import statics, for example: we have a Console class with a WriteLine static method, if I add at top of the file: Import System.Console, the I can use WriteLine directly without the need to write: Console.WriteLine
  • 2
    Hacker!
  • 4
    It's silly but not incorrect. The question is of course why. Two possible options. One : stupidity. Two: take advantage of code completion, so you type retCTRL+SPACE and it gets filled in. Is it worth the 3 extra seconds? Absolutely not.

    I vote the reason as #1
  • 7
    Seriously... No doubt, people think that we are stupid...

    I hope that the person who did this, realised his/her own stupidity and corrected it...

    Otherwise, God save him from his team devs... Considering, they stop rolling on the floor...

    This was seriously hilarious, in a weird sort of way...
  • 14
    Unholy demons of darkness, that is source code made from the antimatter of brain substance. And a very weird way of saying

    return (maxClients <= numClients);

    Whoever wrote that code is probably busy right now writing 4294967296 separate functions to return 32-bit integers.
  • 4
    haters will say its fake
  • 8
    At first I thought wtf, then some more wtf, then i loled and then another wtf came through my mind.

    But this may be actually useful. What if someone wants to log every use of "false". In this case it's just one additional line of code instead of much more in any other case. Imagine how much time you can save. I have no fucking idea why anyone would like to log every use of "false" bool but that could happen... in a galaxy far far away. Who am I kidding, that's totally ridiculous
  • 2
    @beriba if we wouldn't take into account methods names, it could be used to reverse everything with one little change

    But anyways, i think its fake
  • 6
    God I wish I could say this is fake.
  • 3
    @phiter You mean to tell me that this monstrosity is part of an existing production code base??
  • 3
    Next a function will be made with void * and typeof passed in..
  • 5
    Working with many different companies and teams, i stumbled upon some of the most absurd things one can imagine.
    My conclusion is that often "developers" are not really what the word imply but just people with some vague knowledge on the subject, doing the minimum required to please the managers.
    The big problem with that code, IMHO, is that probably there's no particular reason behind it other than "because why not" or "I used to do things like this in another language so ..."
  • 2
    But it is super readable. Does that matter?
  • 6
    @mundo03 It matters because there was no need for the first two functions... It is just a sheer wastage of both time and will only lead to sheer amusement or frustration for the people involved in the project..

    Nothing could be more readable than

    if (maxClients > numClients)
    return false
    else
    return true
  • 5
    @SuyashD95 I think the example put by @Grumpy is also very readable.

    return maxClients > numClients
  • 0
    @phiter Completely agreed...
  • 7
    This guy took abstraction way toooo.... serious
  • 1
    Advocate of the devil here. I can seriously think of reasons why he did this. Lets say you use those boolean methods in other functions and you want to write to a log when false happens, this would be the way to do it.
  • 2
    No sane human can do this, so either there is a reason for this insanity or its a joke.
  • 3
    "13 references"

    ...
  • 3
    Im sorry, how the fuck this retarded post has almost 500 ++ ???? I call it bullshit!!! ๐Ÿ˜‚
  • 2
    @No-one I used bots
  • 3
    @phiter i see ๐Ÿ˜ i hope that they are written in the same way as in this post๐Ÿ˜๐Ÿ˜
  • 1
    @gitpush this is useful. Do you by chance know what happens if you import two classes (assuming this is possible) and call a static method they both have? Compiler error I suppose?
  • 0
    Congrats on the 500!
  • 2
    That is what I call the OOP syndrome.
  • 2
    There are two types of people...
  • 0
    Just swap the return values of functions before resigning. :')
  • 2
    Tell us the story of this code
  • 0
    This reminds me some code that went outsourced to junior programmers in india and charged 10K back to us...
  • 1
    It's very flexible, what if you one day want to change what false is
  • 0
    I hope they wrote unit tests for those functions. That would be amazing!
Your Job Suck?
Get a Better Job
Add Comment