cross-posted from: https://programming.dev/post/54023908

Hi!

I’ve never read any of Uncle Bob’s books. But I have taken interest in “Clean Architecture” as it seems like a good solution to make mid to large sized projects simple to understand and maintain.

I think MVC gets too much coupling and fails at larger projects, same with n-tier. But I’m not sure about anything right now (software design is a very complicated problem after all).

So I was wondering if you friends who have used Clean Architecture in production can share your knowledge and experience with me about this design?

Is it actually good and worth investing in?

Footnote:

I’m especially weighing this architecture because Uncle Bob’s writings are really hit and miss. I don’t see him as a master or guru so I take everything he says with a grain of salt.

  • AlteredEgo@lemmy.ml
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    4 hours ago

    I’ve become disillusioned with such approaches because coders tend to loose themselves in the aesthetics of ideas and architectures. And that can lead to high verbosity for something that could be much simpler, which then makes code harder to read and browse. Basically I doubt that complex software problem can actually be planned and designed without programming them first. That could well be just my own limits.

    So today I prefer a bit of a “return to monke” C-style procedural approach and don’t even like OOP anymore.

    I do wonder if there is a more formal framework for natural language (AI prompt) programming. Maybe LLMs could be used as an actual research tool to explore a high number of different architectures of well defined programs, and then compare them. Like have the same app programmed in hundreds of different languages, designs and idioms, and then compare them to get the answer to your question.

  • Peereboominc@piefed.social
    link
    fedilink
    English
    arrow-up
    6
    ·
    12 hours ago

    I used to like clean architecture. I implemented it in some large monolith applications but later on changed it. What stayed is the seperation of things by giving a dependency to a module/struct/class/object (via a constructor). The object does not need to know what has been passed to it, only that it can for example store something. The storing of something can be saving it to an SQL database, to a file, print it to console, etc. So basically inversion of control. And the basic breakup between the domain logic/business logic and the things that does the heavy lifting like a database handler, API handlers, etc.

    • melfie@lemmy.zip
      link
      fedilink
      arrow-up
      7
      ·
      10 hours ago

      Agreed, DI in moderation can be useful. I generally like to target dependencies with I/O so they can be substituted with test doubles to allow the domain logic to be tested with fast, deterministic tests. On the other hand, I’ve seen codebases that go way overboard with SOLID and create unmaintainable messes that are difficult to reason about.

      • Peereboominc@piefed.social
        link
        fedilink
        English
        arrow-up
        3
        ·
        2 hours ago

        Yeah, that’s always the thing. Sometimes it is good to have a strict guideline/structure to prevent a mess but that itself can be the source if the mess. As it n way to complicated with many unnecessary abstraction layers while a simple direct call to a function would also be good enough.

  • thingsiplay@lemmy.ml
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    17 hours ago

    I say, its worth investing in and learning. Not necessary to force you to do this, but to see it from this view and if its any good. Sometimes drastically different views can change how you program, without completely getting lost into it. In example, a Python or JavaScript programmer who tries out Haskell and learns how it works, does not mean will completely convert to Haskell. But it might give the person good habits reason about future Python and JavaScript code, and prepare and handle it differently.

  • Pissmidget@lemmy.world
    link
    fedilink
    arrow-up
    18
    ·
    1 day ago

    Not the exact book, but the same author.

    I’ve read two of his books (clean code and clean coder), and there are things I agree with, absolutely. There are also things I vehemently disagree with.

    The main value I gained from them was by reflecting on the scenarios and his ideas on approaching them. Afterwards I made up my own mind on the subject.

    They contained a good deal of subjects that I, as a very junior dev at the time, hadn’t even begun to consider, and by being aware of them, I could more easily approach them when encountered in the wild.

    There’s also a historical aspect of knowing what has inspired, affected, or motivated, other ideas and approaches.

    Take it for what it is, one person’s opinions. Some you’ll probably agree with, some you won’t. Just because someone is out was regarded highly in a field does not make their word gospel. It makes it worth thinking about and forming your own opinion though.

    • thingsiplay@lemmy.ml
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      17 hours ago

      I’ve read two of his books (clean code and clean coder), and there are things I agree with, absolutely. There are also things I vehemently disagree with.

      That’s why people should read! I don’t get this how lot of people say one should not read his books, even though the person asking is interested and is unsure if this is the right approach. Read and make up your own decision is the best thing.

  • e8d79@discuss.tchncs.de
    link
    fedilink
    arrow-up
    10
    ·
    1 day ago

    The less you read of Uncle Bobs writings the better but Clean Architecture isn’t really his idea(the original was called Ports and Adapters) its just a name that he coined and it unfortunately stuck.

    I think Clean Architecture is quite useful for the kinds of long-lived application development projects that you will usually encounter in larger companies. Its main appeal in my opinion is that it prevents your domain logic from becoming entangled with implementation details of the environment in which the software will run. This makes changing out dependencies easier in case you need to switch out some 3rd party services.

    Another benefit of using such a well-known architecture in general is that you will have an easier time on-boarding new developers. In a clean architecture project it should be no question where to find, for example, the database context because it will obviously live in the infrastructure layer.

    A drawback of this approach is that it can make an application more complex than it needed to be, especially if you are writing a smallish CRUD application that has little to no domain logic.

    To me the clean architecture is a good default to start with for monolithic business applications, where requirements might change drastically in the future, but as with anything else it doesn’t fit every use case. So, don’t try to write the next high performance game engine with it.

    • Alavi@programming.devOP
      link
      fedilink
      arrow-up
      1
      ·
      18 hours ago

      Thank you for your explanation.

      My work revolves mostly around large enterprise software, so I guess this fits me.

      But can you elaborate why not write a game engine with it? Game engines are also very complex.
      Do you say because of the performance hit of multiple layers of abstractions?

      • e8d79@discuss.tchncs.de
        link
        fedilink
        arrow-up
        1
        ·
        3 hours ago

        Yes, performance is one reason. Clean architecture uses indirect calls a lot. This doesn’t really matter if you are doing IO bound work like reading files and calling databases, but games do a lot of CPU bound work as well to simulate physics and update game state where all that indirection will waste CPU cycles.

        I also can’t really think about a part of a game engine that I would put into the domain layer. The domain layer is the whole reason this architectural pattern exists and if you can’t define that clearly there isn’t a reason to use clean architecture.

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    11
    ·
    1 day ago

    IME it’s an interesting read and some of the problems raised are valid, but the solutions are often unrealistic and overengineered. Same with design patterns, learn them to be aware of the problems, possible solutions, and their trade offs; but don’t feel the need to warp the entire project around it.

  • squaresinger@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    1 day ago

    As with everything, don’t take it as a gospel. It’s a tool that can be somewhat beneficial in the right circumstances, and it can also be abused and lead to horrible results if used dogmatically.

    Uncle Bob is seriously not a master or guru but instead more of a well-known blogger-turned-author.

    (And using “Clean” in the naming of a guideline is an offence that should be punished with… cavities in his teeth.)

  • expr@programming.dev
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    21 hours ago

    Bob Martin is a complete hack. He should not be regarded as an authoritative source and indeed, any claim he makes should be treated as highly suspect. He’s not worth reading.

      • expr@programming.dev
        link
        fedilink
        arrow-up
        5
        ·
        10 hours ago

        He hasn’t done any real software development in decades, and it shows. His books are chock full of terrible ideas and his ideas of “clean” anything are anything but.

        One of the best examples of his hackery is this tweet: https://xcancel.com/unclebobmartin/status/982229999276060672#m

        Completely false misinformation presented as fact from an “authority”.

        Also apparently probably a fascist, based on this and some other tweets I came across while trying to find that one: https://x.com/unclebobmartin/status/1398671193922805761 (apologies for the X link, can’t seem to find this one on xcancel?). I would need to look further since it’s news to me, but it’s hard to imagine any other interpretation of that tweet.

        • thingsiplay@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          10 hours ago

          Having links to backup what you claim is always a good thing, so thank you for this. I have blocked X/Twitter, but do not care about the political statements anyway. So no need to lookup for me.

          For the false information on the technical explanation, well I can’t confirm what it is, because I never really understood Monads. Now that does not mean his his approach to how software should be thought off is wrong. But I understand why someone is careful after such statements (if its plain and simply wrong). The thing is, everyone makes mistakes and false statements at some time. It depends on how often this happens and how the situation is handled, if the person admits it and learns from the mistakes.

          Therefore I wouldn’t just say his books are dumpster fires. I personally didn’t read his books, but there are people who seem to like it. The best is someone reads it themselves and finds out if its for them or not; provided its not false information.

  • VibeSurgeon@piefed.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 day ago

    Clean Architecture insofar as separating your application into architectural layers is broadly speaking a good thing.

    • Alavi@programming.devOP
      link
      fedilink
      arrow-up
      1
      ·
      1 day ago

      I’m specifically talking about the “Clean Architecture” design as described by Robert Martin though.

  • nous@programming.dev
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    5
    ·
    1 day ago

    “Clean” Code, Horrible Performance offers a good argument against it purely from a performance stand point. Well worth a watch. But it also does not even make code easier to maintain. It just smears logic all over the place and makes it harder to understand what is going on. Trying to follow clean code principals just makes your code worse. And if you try to point that out to anyone they just say you are doing it wrong with no proper advice on how to actually improve things.

    • Alavi@programming.devOP
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      1 day ago

      I’m not talking about the “clean code” approach. I’m talking about “clean architecture” for software design.

      I have also heard things about how the multiple levels of abstraction in Clean Architecture can lead to worse performance, but we can always optimize the bottlenecks and skip the abstractions if needed. I also don’t have any actual benchmark of how much is the performance hit.