this post was submitted on 07 Oct 2025
171 points (90.9% liked)

Programmer Humor

27477 readers
1547 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] UnderpantsWeevil@lemmy.world 5 points 1 month ago

I agree that the more verbose style is more explicit, and so more readable.

On its face, its readable. But when you're dealing with 10,000 lines of code in a file, it becomes this ugly morass of extra nothingness to scroll through.

The only part that has me stumped is the unary question-mark operator: private static Singleton? _instance = null;

It transforms a strict variable into a nullable variable. I most commonly see it with primitive types.

So, for instance

int myInt = null

is an illegal assignment, but

int? myInt = null

works fine.

Why does a public class instantiation need this? Idfk. That might be extraneous. But I wouldn't throw away the whole code block rewrite over that one character.