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?

  • aev_software@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    7 days ago

    The main lie about these principles is that they would lead to less maintenance work.

    But go ahead and change your database model. Add a field. Then add support for it to your program’s code base. Let’s see how many parts you need to change of your well-architected enterprise-grade software solution.

    • justOnePersistentKbinPlease@fedia.io
      link
      fedilink
      arrow-up
      0
      ·
      7 days ago

      Sure, it might be a lot of places, it might not(well designed microservice arch says hi.)

      What proper OOP design does is to make the changes required to be predictable and easily documented. Which in turn can make a many step process faster.

      • Log in | Sign up@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        6 days ago

        I have a hard time believing that microservices can possibly be a well designed architecture.

        We take a hard problem like architecture and communication and add to it networking, latency, potential calling protocol inconsistency, encoding and decoding (with more potential inconsistency), race conditions, nondeterminacy and more.

        And what do I get in return? json everywhere? Subteams that don’t feel the need to talk to each other? No one ever thinks about architecture ever again?

        I don’t see the appeal.

        • Guttural@jlai.lu
          link
          fedilink
          Français
          arrow-up
          0
          ·
          2 days ago

          It works in huge teams where teams aren’t closely integrated, for development velocity.

          Defining a contract that a service upholds, and that dependents can write code against, with teams moving at will as long as the contract is fulfilled is valuable.

          I’ll grant you it is true that troubleshooting those systems is harder as a result. In the huge organization I was in, it was the job of a non-coder specialist even.

          But given the scope, it made a ton of sense.

          • Log in | Sign up@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            2 days ago

            But if the contract were an interface, for example, the compiler would enforce it on both sides, and you would get synchronous communication and common data format for free, and team A would know that they’d broken team B’s code because it wouldn’t pass CI and nothing drastic would happen in production.

            • Guttural@jlai.lu
              link
              fedilink
              Français
              arrow-up
              0
              ·
              edit-2
              2 days ago

              At that scale, contracts are multiple interfaces, not just one. And C#/Java /whathaveyou interfaces are largely irrelevant, we’re talking way broader than this. Think protocol, like REST, RPC…

      • aev_software@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        7 days ago

        I guess it’s possible I’ve been doing OOP wrong for the past 30 years, knowing someone like you has experienced code bases that uphold that promise.

        • calliope@retrolemmy.com
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          7 days ago

          Right, knowing when to apply the principles is the thing that comes with experience.

          If you’ve literally never seen the benefits of abstraction doing OOP for thirty years, I’m not sure what to tell you. Maybe you’ve just been implementing boilerplate on short-term projects.

          I’ve definitely seen lots of benefits from some of the SOLID principles over the same time period, but I was using what I needed when I needed it, not implementing enterprise boilerplate blindly.

          I admit this is harder with Java because the “EE” comes with it but no one is forcing you to make sure your DataAccessObject inherits from a class that follows a defined interface.