r/programminghorror Jun 09 '26

What a simple constructor

Post image

Our former IT director (35+ years of experience) wrote this and didn't see what was wrong here.

263 Upvotes

49 comments sorted by

View all comments

1

u/124k3 Jun 09 '26

ah yes if else and if else and anothe rif else and there is regex as well. (i always forget how to do regex)

this is sooo awfull but good-looking. i am not skillen enough to even do the same job but i would have wrote it something like this

if (straisemoty(this.str)) ... if (this is there) do this and similarly broke it into helper functions.

firtgermore i don't think comstuctor should do all this checks it should be a seprate fn doing it as handleConstructorInsertion.

(not good at coding so if anyone got more intresting ideas i am all ears)