this post was submitted on 24 Oct 2023
711 points (97.6% liked)

Programmer Humor

19817 readers
57 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
all 50 comments
sorted by: hot top controversial new old
[–] [email protected] 140 points 1 year ago (3 children)

Let him play in the legacy code. You can just hose him off later before letting him back into the office so he doesn't track it everywhere.

[–] [email protected] 66 points 1 year ago (2 children)

Unfortunately if you let Junior play in legacy code once, it'll learn some nasty habits and make more of it from scratch, usually when you're trying to sleep.

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago)

That's what the line represents. So they can pull you if you do something nasty.

[–] [email protected] 4 points 1 year ago

God, I would love that so much

[–] [email protected] 54 points 1 year ago* (last edited 1 year ago) (2 children)

me when first starting out at a job commenting everything I can
VS
me a couple years in completely lost because I never updated the comments and now none of them make any sense whatsoever

[–] [email protected] 60 points 1 year ago (5 children)

Commenting well is a highly advanced skill. I generally prefer no comments on code since it's less likely to confuse people and I'll merrily purge auto-doc comments and anything like

// getId() returns an id

That comment has negative value.

[–] [email protected] 24 points 1 year ago

I can't help it, I always get the mental image of hands clapping sarcastically when I see something like that.

[–] [email protected] 10 points 1 year ago (3 children)

In my experience refactoring lots and lots of crappy code left by devs long gone, a dev who can write useful comments is by and large a dev who can write code clean and simple enough not to need them. If the code doesn't have informative names and clear separation of concern, chances are a comment won't help because the dev didn't really know what they did that worked in the first place.

[–] [email protected] 14 points 1 year ago

Generally, yes. However I have been known to document exactly why I'm doing something incredibly stupid - because it's required but a stupid third party library which, despite being awful, is still better than implementing it myself as a refactor.

[–] [email protected] 3 points 1 year ago

a dev who can write useful comments is by and large a dev who can write code clean and simple enough not to need them.

my boss is great in this regard and also always has to keep reminding us to write unit tests 😅

[–] [email protected] 9 points 1 year ago (2 children)

Comments should only be used to describe stuff that’s otherwise difficult to convey with code.

[–] [email protected] 18 points 1 year ago (1 children)

The best explanation I've ever heard is:

Comments should state the 'Why' never the 'What'.

load more comments (1 replies)
[–] [email protected] 3 points 1 year ago (1 children)

Yeah. Most of the time I use comments in my algorithms, as they often use some weird optimized black magic which are difficult to understand without comments.

[–] [email protected] 1 points 1 year ago

Like don't set this value to the obvious default. Bad stuff happens

[–] [email protected] 6 points 1 year ago (1 children)

I write a lot of fairly simple scripts in Bash and PowerShell that should be easily understood by anybody else with moderate experience in the language, but I leave a lot of obvious comments because my coworkers don't write any code and are extremely skittish about my automations. I add them basically to quell their fears.

[–] [email protected] 9 points 1 year ago (1 children)

Why are coworkers who don't write any code in the codebase?

[–] [email protected] 7 points 1 year ago* (last edited 1 year ago)

These are scripts that manage stuff on a few hundred user endpoints and a few servers. They were doing basically everything manually until I got here, and the only way I could get them on board with my slow introduction of automation is to let them see it. I have to ensure things don't get too long, complex, or hard to explain, or they start getting nervous.

[–] [email protected] 4 points 1 year ago

I'd rather teach people to comment well through my reviews. Much easier to understand two lines of well written function description in English than 20 lines of code.

[–] [email protected] 4 points 1 year ago

Yeah well now we have git copilot where your comments include AI suggestions.

Now I have TONS more comments

[–] [email protected] 30 points 1 year ago (1 children)

The leash is good unit testing.

[–] [email protected] 6 points 1 year ago (1 children)

Oh, he'll just change the unit test if it fails.

[–] [email protected] 3 points 1 year ago

Unit tests are there to get an @ignore annotation!

[–] [email protected] 29 points 1 year ago (3 children)

There’s also that long time senior dev who’s overly confident in their abilities and force pushes production breaking code directly to master.

[–] [email protected] 12 points 1 year ago (1 children)
[–] [email protected] 9 points 1 year ago

Nah, they’re the one who’s contributing most to the project. Mostly because their code is so garbage no one else can work with it. But that’s not a thing the managers take into account.

[–] [email protected] 10 points 1 year ago (2 children)

Yeet that shit into main. Who needs unit tests, it works on my computer?

[–] [email protected] 9 points 1 year ago (1 children)

If it works in my mind it’s ready for production

[–] [email protected] 2 points 1 year ago
[–] [email protected] 5 points 1 year ago

YOLOdev is the best way to dev

[–] [email protected] 1 points 1 year ago

This shit happened the other week for me. Senior dev pushed the shittiest JS code without testing the day of a production install and it caused us to have to roll back the install after it very predictably caused a bunch of crashes for pages on our public site. Worst part is, the entirety of what he wrote could've been implemented as a CSS media query

[–] [email protected] 17 points 1 year ago (1 children)

Look, it's me.

Just let me rewrite ONE report from scratch so it doesn't check a specific unindexed table that it doesn't actually need to check and causes the report to be killed by MSQL because it takes too long to run.

Please just one rewrite. Please.

Just one little crystal report.

[–] [email protected] 10 points 1 year ago* (last edited 1 year ago) (1 children)

Just one little crystal report.

Ugh 🤮

[–] [email protected] 4 points 1 year ago

I mean I agree with the vibe of that image but holy niche.

[–] [email protected] 15 points 1 year ago (1 children)

Make him unit test it all and then they can do changes that don't break.

[–] [email protected] 8 points 1 year ago (1 children)

Often enough, the old code is so badly intertwined that it's impossible to actually test. Those are the moments where all you can do is nuke it from orbit.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

Well I was going for that... They will surrender before they do any changes.

[–] [email protected] 5 points 1 year ago (2 children)

Why is the junior dev tied to the other one's penis?

[–] [email protected] 15 points 1 year ago

Because everyone sucks at drawing hands

[–] [email protected] 11 points 1 year ago (2 children)

Bro that's not where the penis is located on the body

[–] [email protected] 4 points 1 year ago

Hey, I don't body shame

load more comments (1 replies)