this post was submitted on 03 Nov 2025
123 points (96.2% liked)

Programming

23394 readers
213 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

As a Java engineer in the web development industry for several years now, having heard multiple times that X is good because of SOLID principles or Y is bad because it breaks SOLID principles, and having to memorize the "good" ways to do everything before an interview etc, I find it harder and harder to do when I really start to dive into the real reason I'm doing something in a particular way.

One example is creating an interface for every goddamn class I make because of "loose coupling" when in reality none of these classes are ever going to have an alternative implementation.

Also the more I get into languages like Rust, the more these doubts are increasing and leading me to believe that most of it is just dogma that has gone far beyond its initial motivations and goals and is now just a mindless OOP circlejerk.

There are definitely occasions when these principles do make sense, especially in an OOP environment, and they can also make some design patterns really satisfying and easy.

What are your opinions on this?

you are viewing a single comment's thread
view the rest of the comments
[–] Valmond@lemmy.world 0 points 4 days ago (2 children)

Show me one.

I mean I have worked on 16bits platforms, but nobody would use that code straight out of the box on some other incompatible platform, it doesn't even make sense.

[–] Guttural@jlai.lu 1 points 15 hours ago (1 children)

Emulation code where you expect unsigned integers to wrap around instead of being UB is a good example, because it was guaranteed for programmers working on the emulated systems.

[–] Valmond@lemmy.world 1 points 15 hours ago (1 children)

That's just how it works and have always worked. You can use an unsigned char on a 64 bit system and it'll behave like on the Commodore 64. I don't understand what you are trying to show.

[–] Guttural@jlai.lu 0 points 15 hours ago* (last edited 15 hours ago) (1 children)

When a system uses words of a specific size, you need to use the same size for wraparound behaviour to work as expected. Incrementing 0xffff by one needs to return 0. It's easy if you use a uint16_t. Not so much if you use an unsigned of unspecified length.

[–] Valmond@lemmy.world 1 points 14 hours ago

We are in a total agreement here.

[–] p_consti@lemmy.world 4 points 4 days ago (1 children)

Basically anything low level. When you need a byte, you also don't use a int, you use a uint8_t (reminder that char is actually not defined to be signed or unsigned, "Plain char may be signed or unsigned; this depends on the compiler, the machine in use, and its operating system"). Any time you need to interact with another system, like hardware or networking, it is incredibly important to know how many bits the other side uses to avoid mismatching.

For purely the size of an int, the most famous example is the Ariane 5 Spaceship Launch, there an integer overflow crashed the space ship. OWASP (the Open Worldwide Application Security Project) lists integer overflows as a security concern, though not ranked very highly, since it only causes problems when combined with buffer accesses (using user input with some arithmetic operation that may overflow into unexpected ranges).

[–] Valmond@lemmy.world -1 points 4 days ago

And the byte wasn't obliged to have 8 bits.

Nice example, but I'd say it'skind of niche 😁 makes me remember the underflow in a video game, making the most peaceful npc becoming a warmongering lunatic. But that would not have been helped because of defines.