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
[–] 0 points 9 months 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.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 4 points 9 months ago (1 child)

    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).

  • source
  • parent
  • hideshow 2 child comments
  • [–] -1 points 9 months 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.

  • source
  • parent
  • [–] 1 point 9 months ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 9 months ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments