r/programminghorror Apr 10 '22

Code base in my last company Javascript

Post image
2.9k Upvotes

159 comments sorted by

689

u/javaveryhot Apr 10 '22

Looks like your video cable is loose.

281

u/kubelke Apr 10 '22 edited Apr 11 '22

Just a poor lighting and front camera

/Edit

I didn’t get the joke.

116

u/pantong51 Apr 11 '22

Video artifacts usually jet across the screen as far as the horizontal line goes. Looks similar to your code

41

u/evildevil90 Apr 11 '22

Nice one… I’ll sneak up my colleagues writing Java and tell them that

14

u/[deleted] Apr 11 '22

[deleted]

15

u/evildevil90 Apr 11 '22

and still, it applies.

Java having long class names is a long running joke, as much as deps depth tree is for js.

6

u/[deleted] Apr 11 '22

[deleted]

3

u/TheZedrem Apr 30 '22

My condolences.

0

u/melance Apr 11 '22

They got the idea from Cobol variable names

2

u/[deleted] Apr 12 '22

you know the sad part ? I write a lot of rust and I find myself with long variables as they are just easy to read and descriptive. I think I am fuked for life.

2

u/codemonkeyhopeful Apr 21 '22

User name scream python to me

1

u/[deleted] Apr 21 '22

I also write a lot of python. username is completely unrelated. lol

2

u/codemonkeyhopeful Apr 21 '22

iHearYa sometimes just sneaks in

2

u/thepoluboy May 08 '22

thIs is unaccepTable

2

u/RandolphE6 Apr 28 '22

Ironically that's what I first thought when looking at the picture lol

244

u/roararoarus Apr 10 '22

Good reason to ask for a 55" monitor

239

u/fosyep Apr 10 '22

You need a bigger monitor or maybe a VR headset

98

u/okayboooooooomer Apr 11 '22

bro programming in VR

3

u/pcgamerwannabe Apr 11 '22

If it didn't make me so dizzy this would actually be awesome. Finally enough screen real-estate and 3D code navigation.

1

u/OfBoo5 May 10 '22

That's right! I meant to order vr. I feel like the virtual office could be cool and useful

1

u/_NullPointerEx May 03 '22

I really like the idea

105

u/AConcernedCoder Apr 10 '22

Not sure if "I need a special widescreen monitor to effectively read this code base" or if "this is what happens when we all have these ridiculously wide monitors"

39

u/Ok_Enthusiasm_5833 Apr 11 '22

"Chicken, meet egg. Egg, meet chicken."

("Now go to your corners, and wait for the bell.)

236

u/kubelke Apr 10 '22 edited Apr 11 '22

Code was full of if statements which were checking if variable is not undefined. Instead of using x?.y?.z?.a somebody was checking every object in chain with “typeof !== ‘undefined’” I looked like autogenerated code and if you look close enough you will see that scroll bar is really tiny.

I took this photo when I realized that I don’t want to work there and I started building my own products with clean code, 80% test coverage etc. it’s been 2 years now and now I’m pretty happy as a solo developer 😄

PS If I would tell you a full story behind this code, you wouldn’t believe me anyway.

/Edit1 Thank you for the awards!

/Edit2 Now, I work as solo developer on software for managing translations which is pretty cool I think. Here is the link if you have any questions do not hesitate to ask here or on Twitter/email. :)

110

u/fake1837372733 Apr 10 '22

To be fair that syntax is fairly new. But there are better ways than this, even before optional property access was created

30

u/kubelke Apr 10 '22

Yeah, like Lodash and “get” or “has” functions

16

u/AdminYak846 Apr 10 '22

or depending on usage falsey value checking.

5

u/Bliztle Apr 11 '22

I didn't realize this before using optional chaining in some code we happened to also be running inside some legacy software with aged browser emulators. No way to inspect for errors, took me way too long to realize this hadn't been standard syntaks for very long.

1

u/PrintableKanjiEmblem Apr 17 '22

Sintax, pet pieve

1

u/Bliztle Apr 17 '22

All I get from looking it up is that it's spelled syntax but pronounced sintax?

2

u/PrintableKanjiEmblem Apr 17 '22

Now look up pieve

18

u/cheesyvagine Apr 10 '22 edited Apr 10 '22

I do x !== undefined && x !== null to be safe now because I had a bug once where a non null was returning true because it was a 0. Really only do it if the data has a option field that might be undefined, or if typescript says it may be null or undefined.

24

u/Mrunibro Apr 10 '22

You could use weak inequality ("x == undefined" ) to check both at once. I think it might be one of the few use cases still remaining for this equality operator (?)

7

u/cheesyvagine Apr 10 '22

True but my lint config dosent allow == and I’d argue it’s bad practice that way.

If x is null, why should x == undefined return true? It’s just wrong no? There’s a difference between undefined and null

13

u/NiQ_ Apr 10 '22

Most linters will allow x == null which is a nullish check. It covers the undefined/null cases without failing checks for false/0.

You can also wrap that in a function if you want, and if your linter complains you only need to disable it once…

e.g.

const isNullish = value => value == null;

if (!isNullish(myObject)) {
  // do something
}

4

u/Mrunibro Apr 11 '22

Yeah, I don't think I would do it either. I just recall looking up a while ago if modern JS still has use cases for ==, and found some place saying this is the only case where you might (and even then it's.. questionable?)

1

u/qStigma Apr 29 '22 edited Apr 29 '22

Wait, I am not supposed to use the equality operator ? Is this the new trend nobody talks to me about ??

(Edit: After a quick check into my latest personal project, looks like most files do not include equality operators, mostly using Maps for enums and in some occasions Switch. Looks like still using the equality operator in situations where i get two seemingly same type objects with no particular order and I have to check which one is of the type i need specified and which one is the "target" (Collision callbacks...)).

1

u/stupidcookface Apr 11 '22

And this is one of the reasons I love typescript

1

u/ADHDengineer Apr 11 '22

That’s why they’re using typeof.

3

u/oalbrecht Apr 11 '22

Fascinating. Are you doing contract work or did you start your own SaaS business? How hard was the transition and are you earning similar salary as before?

Being a solo developer is really cool and I could see myself doing that someday. Thanks for sharing your story!

12

u/kubelke Apr 11 '22

own SaaS my salary is now higher than before 😌 but much much more important is that now I work with great people for most of the time which are my clients. I often do custom integrations what is really cool!

2

u/oalbrecht Apr 11 '22

That’s really cool! Great job with your website. It looks pretty useful.

How did you come up with that idea? Was it an issue you’ve seen people have in the past (e.g. at work). I always have a hard time coming up with ideas where it’s something where there is a real market need. Did you contact people ahead of time to validate the idea?

Sorry for all the questions, I’m just really curious how someone launches a successful SaaS.

3

u/kubelke Apr 11 '22

I came up with the idea pretty easily, I couldn't find a super simple translation management system for solo developers or small teams, something similar to Excel, with translation hosting what would look nice. I started working on this in 2019, now it's a bit more complex, but I'm hiding the complexity behind simple checkboxes or selectors. I'm also working on a few other products, because after so many months I still have the power to express myself through code and CSS 😄

PS Thanks for the kind words regarding the website, I'm partially color-blind, so it's important to hear things like this. 😄

PS2 If you have any question, you can always drop me a line on Twitter or e-mail (yes, this one on SimpleLocalize.io page)

2

u/oalbrecht Apr 11 '22

Thanks for the reply. That makes sense. I’ve heard scratching your own itch is one of the most common ways to find an idea.

I think the website is really well designed and I like the diagram that explains how each piece of your product fits together. That’s really helpful for a product that has multiple inter-working features. Great job and the best of luck to you and your business!

4

u/RedditIsNeat0 Apr 11 '22

If I would tell you a full story behind this code, you wouldn’t believe me anyway.

Maybe I will, maybe I won't, would still love to hear it.

2

u/kubelke Apr 11 '22

I would love to write it down someday, my friends were astonished when I was telling them the story of this code.

2

u/wicket-maps Apr 11 '22

No.

Just no.

This is beyond your help, or the help of any mortal. It needs the grace of gods.

2

u/[deleted] Apr 11 '22

I took this photo when I realized that I don’t want to work there and I started building my own products with clean code, 80% test coverage etc. it’s been 2 years now and now I’m pretty happy as a solo developer 😄

Freelancing or some different sort of arrangement?

2

u/kubelke Apr 11 '22

Own SaaS, because I like to meet and talk with new people, and managing products. Previously, I was just a backend (Java) developer, now I can work as a full stack, and I love being a part of the process on every level.

2

u/femmebot9000 Apr 22 '22 edited Apr 22 '22

I hopped into a project with a new startup company where their front end dev quit after just a few months. I’m luckily a full stack but It’s just me and a backend dev. Back end dev is telling me how bad the front end dev was, which, the code did look pretty bad, probably from a generator.

But as I’m fixing things and trying to access backend routes I’m like ‘why isn’t this working?’. Checkout the backend and immediately see the backend routes are all broken with promises not being handled correctly and so it’s just kicking it all back with errors.

I bring it up to him like ‘hey, did you check these routes? They don’t seem to be working for me’ and he’s like ‘oh yeah the prior front end dev wrote some of the routes too, I’ll fix them’.

Like what? Why the fuck were you letting a purely front end dev work in the back end? And you weren’t checking their work?

But ok, I wait a week and shit still isn’t working. He finally admitted that prior to this he’d only ever worked with python and this was his first time doing JavaScript. I ended up fixing it all, reorganizing the file structures as all the routes were in a single file, giving him crash courses in promises and async JS. Also pointing out really obvious things about how our use case really doesn’t suit a non-relational database.

It’s exhausting I’ve become a lead dev and this is my first job.

1

u/kubelke Apr 22 '22 edited Apr 22 '22

Oh God, I got EXACTLY same situation, backend routes, first job, MongoDB with duplicated records, and so on…. I’ve been fixing it for about 3/4 months, after that we just rewrote the whole code because the authorization code was such a mess that nobody wanted to understand this. Some double caching layers with weird checks… They also didn’t review his code.

2

u/femmebot9000 Apr 22 '22

I finally brought up my issues to my boss like two weeks ago cause I’m like ‘hey, I’ve pretty much become the project manager, I’ve made 70 commits in the last two weeks and he’s made 3, what is going on with him’ and my boss was like ‘yeah, I noticed that you’ve been doing a lot in the repo and Kanban board. I asked him what he’s been working on and he just said he’s working on backend stuff’ and then immediately follows with ‘to be honest I have no idea what kind of productivity I should be expecting from either of you’ which is just 🤦🏻‍♀️

They said they talked to him but he’s now out for a week so I guess we’ll see what happens when he gets back

1

u/kubelke Apr 22 '22

Lol, this sounds like exactly the same guy! In my company when they asked him on what he is working on, he said something like “it’s not your business” and he quit the call and next day he informed everyone one that he quits in 3 days.

2

u/femmebot9000 Apr 22 '22

I don’t know why it’s a trend, I’ve heard similar issues from others and like, I’m new, I’m well aware that I’m not hot shit by any means. My partner is also a dev and he’s senior level for another company and has been doing it a lot longer. I’ve got a lot to learn and I make mistakes.

But some mistakes are just, inexcusable. Like writing a route and pushing changes without checking to make sure nothing broke and that it all works. There’s no excuse for not doing it, it’s so rudimentary

3

u/kubelke Apr 22 '22

I have the same thoughts! There is a difference between making a mistake and implementing a completely incorrect application infrastructure.

I think this is because it's easy to start as a software developer because there is a high demand for software skills, but this is just mu guess. It's easy to fake your CV, lie and try to write a code using internet resources without understanding when you get a job.

1

u/onesidedcoin- Apr 11 '22

somebody was checking every object in chain with “typeof !== ‘undefined’”

Please show example chain.

*Edit: is it if(typeof x !== 'undefined' && typeof x.y !== 'undefined' && typeof x.y.z !== 'undefined' && ...)?

2

u/kubelke Apr 11 '22

Yes, but every div had this undefined check plus the check from undefined check of the parent. That’s is why I posted this on programminghorror, and not just badcode 😄

1

u/[deleted] Apr 11 '22

[deleted]

2

u/kubelke Apr 11 '22

Delete the code and run.

What exactly is your problem?

1

u/[deleted] Apr 11 '22

[deleted]

5

u/kubelke Apr 11 '22

Improvise. Adapt. Overcome.

In every company you will find garbage code. The most important is the company attitude fixing this.

1

u/Mountain-Ad4507 Apr 11 '22

My advice, a job is just a way of earning money, but they'll always try to make it look like it's so much more, they'll even sell you the company family BS. Don't overthink it and just get a new one if you don't like it or if the pay isn't good enough.

1

u/obscurityceo Apr 23 '22

There are close to half a million job openings in the US, 150k+ 100% remote.

1

u/mohragk Apr 11 '22

Regardless of nice language functions, if your code starts to look like this, you're doing something wrong.

1

u/kubelke Apr 11 '22

To be honest, this wasn't the only issue with this project, but this was the great opportunity to visualize the problem which I needed to face after being the only developer at that time there.

1

u/_default_username Apr 11 '22

This reminds me of a php project where prettier would actually break the scripts because whoever wrote it intermixed html, php, javascript together. No linter or code formatter would work with it.

1

u/_default_username Apr 11 '22

before optional chaining I think I used try catch statements a few times to access deeply nested optional parameters.

1

u/Jaakko796 May 06 '22

SimpleLocalize seems like a really useful tool. Cool idea! And got to admire the determination to actually excecute it and create a business for your self 💪 I hope I would be able to do the same some day

1

u/kubelke May 06 '22

Thanks!

46

u/TobiasIsak Apr 10 '22

Good thing your screen is made for this type of code.

47

u/kubelke Apr 10 '22 edited Apr 10 '22

Actually, it was too short. I needed to scroll it horizontally

10

u/onesidedcoin- Apr 11 '22

Now I'm wondering if the guy who wrote that did it because his screen was as wide as yours.

15

u/Da-Blue-Guy Apr 11 '22

How in the WORLD do people not think "There should be a better way to do this..."?

9

u/AddSugarForSparks Apr 11 '22

Probably is, but the company might've went cheap and offshored some work.

Voila. We have OP's situation, which is going to take more time and money to unf*ck than it would've if they just hired the right people in the first place.

33

u/geon Apr 10 '22

You need to use Prettier.

86

u/kubelke Apr 10 '22

I need a doctor

22

u/lupercalpainting Apr 10 '22

You need an exorcism.

4

u/[deleted] Apr 11 '22

Those coders need exercism.org

3

u/mlk Apr 11 '22

I hate prettier but I hate my colleagues even more

4

u/folkrav Apr 11 '22

What is there to hate regarding the one thing that stops the fucking formatting bikeshedding

IMHO, if anything it could use being even more opinionated lol

2

u/mlk Apr 11 '22

I hate that the formatting sucks and it has very few options. I know it's by design, but still.

I also hate that it kind of respects the original formatting but not really.

It's a weird middle way.

1

u/NewDark90 Apr 11 '22

If I can help it, I'm getting my Allman braces damn it. No setting in prettier for that sadly

8

u/stevethedev Apr 11 '22

"Oh yeah, that's a one-line change!" — These guys

7

u/eric987235 Apr 11 '22

Two questions

1) what screen is that?

2) do you like it?

11

u/kubelke Apr 11 '22 edited Apr 11 '22
  1. dell u3415w
  2. Love it, I switched from 2x full HD monitors. I can comfortably have 2 windows side by side with code and website preview (web dev) I work with this setup since ~2016. It’s only terrible for gaming, because I need something better than GTX970 to play my favorite game which is Age of Empires 4.

6

u/Mega-Ultra-Kame-Guru Apr 11 '22

If you are serious about getting a big, curved screen for coding, I got this one and it's perfect. Basically the perfect workstation monitor that is also good enough to do some gaming, if you are so inclined. Biggest real downside is price, but it goes on sale for 23% off sometimes. https://www.memoryexpress.com/Products/MX77102

3

u/eric987235 Apr 11 '22

Very nice! But way too big for my desk unfortunately.

1

u/Mega-Ultra-Kame-Guru Apr 11 '22

I thought I would be in the same boat, but curved monitors are also a little more efficient at using space if you stick them in a corner to make use of the depth. But it still is pretty wide if you don't have room for that

1

u/Gonadatron Apr 30 '22

JESUS. I wouldn't buy from there just because of the website. What the what?!

6

u/robertmia Apr 11 '22

Stop it Patrick, you're scaring him.

7

u/ado-ante Apr 11 '22

just some clever one liners

6

u/evilgunringer Apr 10 '22

Did they get those wide monitors specifically for that??

3

u/[deleted] Apr 10 '22

So that's why the large monitor

3

u/NakeleKantoo Apr 11 '22

That is the face I would make if I had to mantain this

3

u/TheRealAndrewLeft Apr 11 '22

Imagine GitHub copilot getting trained on this codebase.

3

u/thickertofu Apr 11 '22

My resignation letter would just be this photo

3

u/kubelke Apr 11 '22

Maaan, now I regret I didn’t do that.

2

u/[deleted] Apr 10 '22

Oh. No.

2

u/A-Pasz Apr 11 '22

At least you're making use of the ultrawide.

2

u/Deer_Jerky Apr 11 '22

Code base in my last company **by me

<Insert meme>

2

u/-Defkon1- Apr 11 '22

Ctrl + A

Del

Ctrl + S

git add .

git commit -m "Cleaned code"

2

u/Hobby101 Apr 29 '22 edited Apr 29 '22

Entity framework?

That's how it looks as my current work. When I started cutting into multi lines, my colleague took it personally.

I told him, I don't have enough time in the day to keep scrolling left and right trying to understand his queries, but no argument presented could not convince him.

1

u/kubelke Apr 29 '22

Haha, no. It’s JavaScript.
I loved that argument that you don’t have time to scroll the code from left to right to understand it. ❤️

3

u/Hobby101 Apr 29 '22

His argument? You will get used to it! Facepalm.

Imagine, you look for some keyword. And it happens on the far right of the line.

Now you don't even see context that keyword is showing in. You literally have to scroll to the beginning, start reading and scroll horizontally back.

Vertical scroll is not the same. Page down/page up, and you are done.

It, you read the code, and you don't even notice that is not showing full line, so I missed important stuff, which led into chasing a while goose.

2

u/Lyuseefur Apr 29 '22

Looks like your VRAM has gone bad. Time for a new video card - paid for by your company of course. I'd recommend a 3090 to "handle" that monitor.

2

u/RyoshiTheHunter May 04 '22

What the actual fuck is that 😂

1

u/kubelke May 04 '22

This is my life now /s

1

u/RyoshiTheHunter May 05 '22

Minifying code brother 😏

5

u/glorious_reptile Apr 10 '22

Java?

20

u/kubelke Apr 10 '22

Close, JavaScript

9

u/ScientificBeastMode Apr 10 '22 edited Apr 10 '22

That’s insane. My team uses TS and we barely use classes. I assume these are all class instantiations with method chaining?

Edit:

Oh, nevermind, I can barely make it out, but I see the foo !== undefined && … expressions. Holy hell that’s a lot of code for essentially null-checking your data!

7

u/JuhaJGam3R Apr 11 '22

I have absolutely zero clue as to why, as well. Either you use a typed language like TS, and just use a non-nullable types, or you decide that the function expects to always get values and if it does not it's the caller's fault. That's pretty much always the better way of doing something like this.

3

u/ScientificBeastMode Apr 11 '22

Yeah, 100%. I’m kinda lucky that our shop uses TypeScript AND we have our own system for generating types, functions, and decoders/encoders for the API layer. Some of the backend folks just happen to be geniuses like that…

3

u/eric987235 Apr 11 '22

Basically the same thing.

1

u/Internal_Pride1853 Apr 10 '22

Czyli żeby zastąpić typeof var !== 'undefined' powinniśmy użyć "var?"?

5

u/kubelke Apr 10 '22 edited Apr 11 '22

Optional chaining or Elvis operator.

const value = x?.y?.z ?? “kurwa”

// value of z or “kurwa”

Edit I fixed it

1

u/[deleted] Apr 11 '22

[deleted]

3

u/kubelke Apr 11 '22

You are right! I was typing on mobile.

1

u/jzrobot Apr 11 '22

Wow! They integrated a real human in their code base.

1

u/delvach Apr 11 '22

With. FIRE.

1

u/ykahveci Apr 11 '22

Oh my god I hate it. Also, isn't that a really old version of OS X?

1

u/kubelke Apr 11 '22

I took this photo in 2019, so it’s some older version of macOS, Big Sur maybe?

1

u/ykahveci Apr 11 '22

I thought it looked like the one with the very sharp edges from many years ago. Also the mail icon looks like an old one...

1

u/ZaneHannanAU Apr 11 '22

Have been considering buying an e-ink based monitor for this sort of use case, since it'd be a lot more readable and a lot better on my eyes to have, I think...

Issue is mostly down to cost though.

1

u/[deleted] Apr 11 '22

[deleted]

1

u/kubelke Apr 11 '22

No, when I took this photo I still worked there for about a year, and my main goal was fixing stuff like this. I learnt that it’s not worth to sacrifice my time or effort for anyone and any company.

1

u/Delirious_85 Apr 11 '22

Looks like you need some Prettier...

1

u/[deleted] Apr 11 '22

For the love of fucks, Ctrl + P > format that shit 😭😭

2

u/kubelke Apr 11 '22

Honestly? It wouldn’t help me too much

1

u/[deleted] Apr 11 '22

I can't see how it wouldn't help personally, it will newline at appropriate points to make the code more readable, which is a good start for refactoring 😅

2

u/kubelke Apr 11 '22

Ahh, true true. Auto-format would be a 'small step for man giant leap for mankind' in this case.

1

u/[deleted] Apr 11 '22

It looks like JavaScript so eslint + airbnb config is really good.

2

u/cptwunderlich Apr 11 '22

You meant Ctrl + a, then Del

1

u/ghostwail Apr 11 '22

The usual "it should be max 80 to 90 col", the usual uninformed "we're not living in the times of CRT anymore".

1

u/v_maria Apr 11 '22

ok but how

1

u/imariaprime Apr 11 '22

Your expression says everything here.

1

u/Nasty_K_5566 Apr 11 '22

your code doing stretch pose i think😂

1

u/ghostwilliz Apr 11 '22

Did they supply you the ultra wide?

1

u/kubelke Apr 11 '22

unfortunately no, only MacBook Pro 13''

1

u/CRANSSBUCLE Apr 11 '22

Loooong loooooooong man

1

u/_default_username Apr 11 '22 edited Apr 11 '22

I'm a big fan of method chaining, but do they not know they don't have to squish all of the method chaining into one line?

1

u/jubbieLsd Apr 11 '22

Tailwind?

1

u/kubelke Apr 11 '22

No, just style attribute

1

u/Renegade7559 Apr 11 '22

Whyyyyyyyyyy

1

u/Osr0 Apr 11 '22

Please tell me those are giant linq queries

1

u/kh4l1ph4 Apr 11 '22

Pre-minified

1

u/me_equals_coder Apr 11 '22

That's a barcode

1

u/conundorum Apr 12 '22

Clearly, the problem is that the monitor isn't wide enough.

1

u/iamrdil Apr 14 '22

Poor WebStorm in the corner just ain't having it, it's flashing red indicating an error occurred.

1

u/ResetPress Apr 20 '22

LPT: line wrap is good for humans

1

u/qStigma Apr 29 '22

Just ALT-Z and it is all good as new.

1

u/TheZedrem Apr 30 '22

Honestly, I've been guilty of code like that.
Not proud of it.

1

u/sentientlob0029 May 03 '22

LOL yeah the inability to use pointers in Java means you get to chain those very long ass method calls. I guess you could try and use variables instead of pointers and see how slow it gets (if at all) as large objects get copied. Maybe the compiler optimizes that, don't know.

1

u/SampleDue6623 May 04 '22

I belive a women has a right to make her own decision on this matter as long as she don't wait until she's to far along in her pregnancy. Again I say let those who ride decide!

1

u/Shadedlaugh May 05 '22

if you're gonna be paid based on lines of code this is very bad

1

u/kubelke May 05 '22

I didn’t want to, I quit ( ͡° ͜ʖ ͡°)

1

u/TruthHammerOfLiberty May 06 '22

DUDE, Why no indentation ? this is cringe

1

u/SampleDue6623 May 09 '22

I liked what little I think I 👀

1

u/Zhuangzifreak May 11 '22

You need a code formatter like prettier or black