Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Shisuki6057yThe previous dev had the brilliant idea of inputting sex by either 0 or 1..
*Hears SJWs crumbling down having heart attacks* -
@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... -
Shisuki6057y@araxhiel Mate if you have ANY advice for me I'm all with you! First time I encounter this kinda situation x))
-
@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 ) -
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. -
Shisuki6057y@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! -
Shisuki6057y@Torbuntu What you said is making me unbelievably uneasy right now xDD
(Also it's 18..) -
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?
-
skprog19167yI love how he didnt comment which was 0 and which was 1 so what is female is 0 huh than what.
-
I was expecting the first line inside the constructor to be a try block. Tell me, does it catch all all exceptions?
-
Shodan4987ySex 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. -
7Raiden8787yTwo 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 :) -
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. -
pfish2697yWhat bothers me ist that there is a variable called FONT and a variable called theFont, i mean its not even commented
-
taglia5717ySomehow, only French people had the guts to write code IN FRENCH (variables, comments, and so on..)
-
@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 😂 -
Root825997y@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) -
aaxa24267yThe fact that the arguments are in French gave me more cancer than the number of arguments to that constructor
-
aaxa24267yAlso, underscore in the class name and mix of English and French names makes me oven more sick xD
-
The FONT instantiation in that class is making me insane. Seems like blended concerns.
-
Shisuki6057y@DefiniteGoose not mine but yeah, that's a nasty habit of some French speaking programmers
-
freeme8227yHoly shit, does that mean I can call myself a programmer if I don’t create a constructor with that many parameters?
Related Rants
Yes, that's an 18 arguments constructor.. there's 21 other classes and I'm afraid of looking into them.
rant
legacy code
kill me already
code cleaning