149
Shisuki
7y

Yes, that's an 18 arguments constructor.. there's 21 other classes and I'm afraid of looking into them.

Comments
  • 116
    What sex are you?
    Oh. 13.
  • 38
    The previous dev had the brilliant idea of inputting sex by either 0 or 1..
    *Hears SJWs crumbling down having heart attacks*
  • 6
    @Ashkin LOL... Wait... What 😂?

    (Ah, forget it, I got it now that I've read the comments and saw in ore detail the constructor)

    And, that screenshot opened the "Pandora's Box" of my memory xD in a "quite big" project were I worked there are (because I didn't worked in/reviewed all the codebase) creatures like that constructor 😂

    Even worse (IMHO), there are some webservices (and WCF endpoints too) in that project that are just like that... 😂 I don't know what we were thinking back then...
  • 2
    @araxhiel Mate if you have ANY advice for me I'm all with you! First time I encounter this kinda situation x))
  • 9
    @Shisuki take a deep breath, and exhale slowly as you can, and try to not:

    a) cry
    b) react like Homer Simpson when Marge told him that she was pregnant (obliged reference: https://youtu.be/Ijb6o1lxspI )
  • 5
    On the serious side of the comments...

    What we did in several cases, was to use public properties to set the values that we were needing inside the object/class.

    So, in that way, instead of having an overloaded constructor, we instantiated the object, and then passed the values to the properties (not at once... Well, perhaps sometimes yes, but in other situations we passed as they were required).

    Sometimes we even made objects that encapsulated all those properties and send them (the objects) into the class with the (former overloaded) constructor.

    Sometimes we did both 😂

    I know that there are better ways/practices to solve those kind of situations, but that were the ones that worked for us.
  • 3
    @araxhiel

    Okay, done crying with Homer as background noise c:

    Yeah that's a way of doing it.. I was thinking of splitting the class into several parts as it's a long one and I'm pretty sure doesn't abide by the single responsibility principle. Thanks for the support man!
  • 1
    @Torbuntu What you said is making me unbelievably uneasy right now xDD
    (Also it's 18..)
  • 0
    @Torbuntu I know man, those were dark days for many of us 😭
  • 1
    There are so many things wrong with that. We can simply conclude the writer was either extremely inexperienced or just clueless. Everything a “String” except “sex”? Srsly?
  • 2
    I love how he didnt comment which was 0 and which was 1 so what is female is 0 huh than what.
  • 5
    Sex could be a Boolean...............

    *Sjw triggered*
  • 1
    I was expecting the first line inside the constructor to be a try block. Tell me, does it catch all all exceptions?
  • 4
    Sex is an integer because it's supposed to take in the number of Y chromosomes. Obviously /s

    More seriously, I don't think Affectation_Provisoire (temporary assignment) has any right taking in assignees' (?) information as separate arguments. Just create a proper "Person" class and pass that in, if possible.
  • 0
    I would rather re-write everything, than work with string type and string type2
  • 5
    Two things gave me cancer:

    - The Underscore in the middle of the class name

    - The name of some variables are in French (I guess it's French, not sure :P)

    Also, probably this class started out with a constructor of 2, 3 args, but then escalated with the usual "we need this variable downstream" so you end up incrementing constructors variable everywhere.

    What I usually do is to create a struct/class (depending on the language) that holds just the args to pass in the constructors, so that I don't have to change the API and the way it's called!

    This doesn't solve the 21 args to pass to the struct though :)
  • 0
    Ugh-huh
    Note the language
  • 0
    @Ashkin ahahahahha
  • 0
    @Shodan Lol. Great job on figuring out the chromosomes thing. 😂😂
  • 1
    Of course the code is bad. It's because it is not written by you.
  • 5
    An advice to all devs: write your code in English please!
  • 2
    @Shisuki you may consider builder pattern to refactor this.
  • 4
    I don't know how nobody mentioned this, but a way to solve this is using the Builder pattern. It can get a bit verbose, but it lets you have optional arguments. I prefer wrapping all arguments in an options object, but this looks like java, so you'll have the same problem when creating that options object.

    Also, this class is definitely doing too much, since it has a lot of user data (names, sex, etc), some kind of view logic (the font declared on the top) and even a file path. You should try to split that into several classes that each do their thing: hold user data; format user data for display; save/read user data to/from file.
  • 2
    @tirthaguha ah, you were faster. 😁
  • 0
    @Ashkin
    0=male
    1=female
    2=transsexual
    3=hermaphrodite
  • 3
    What bothers me ist that there is a variable called FONT and a variable called theFont, i mean its not even commented
  • 1
    bool sex
  • 1
    Somehow, only French people had the guts to write code IN FRENCH (variables, comments, and so on..)
  • 1
    wtf was that programmer thinking
  • 1
    @taglia not only French do that... I've stumbled across various codebases with everything in Spanish, or worse 😂 in Spanglish LOL

    (Edit: and those codebases were/are (I guess) for projects that were used outside Mexico)

    Also... As a side note, and in an anecdotic way: In a certain project we used to enter values (you know, the classic "Person" class) that, for us were funny, cause the name's were innuendos (albeit I don't know how correct an innuendo can be related to an "albur") that mostly only we get it 😂
  • 2
    @kenogo Yes, I immediately assumed enum when I saw the int. However, unless they're imported from a config file, that's a very poor way of doing it -- and even in such an instance I would still prefer string consts for ease of debugging. The best approach would be to define its own class/type to guarantee proper values and conversions.

    (But lol, like everything about the displayed code is a poor way of doing things. So)
  • 0
    The fact that the arguments are in French gave me more cancer than the number of arguments to that constructor
  • 1
    Also, underscore in the class name and mix of English and French names makes me oven more sick xD
  • 0
    Why does this remind me of Windows API functions...
  • 2
    The FONT instantiation in that class is making me insane. Seems like blended concerns.
  • 1
    Zach you're dead to me :p
  • 1
    @MrJDev Eyy ye fucker that wasn't even my code! xD

    But yeah.. I'm mostly dead anyway
  • 1
    @Shisuki I'm still blaming you :D
  • 0
    Also french!
  • 3
    Type and type2, great names!
  • 0
    @DefiniteGoose not mine but yeah, that's a nasty habit of some French speaking programmers
  • 1
    French code is a mess .... Because of accents
  • 0
    Dictionaries
  • 0
    Holy shit, does that mean I can call myself a programmer if I don’t create a constructor with that many parameters?
  • 2
    When the smiley face looks like an AND gate
    #computerengineering
  • 3
    @Ashkin useful with where we are today with all the I identify as........ crap.. 😂
  • 1
    @sladuled hahaha
    Maybe an n<->n mesh would fit better? 😅😧
  • 0
    #stringlytyped programming
  • 0
    Isn't having 0 or 1 as gender a death sentence in today's society?
Add Comment