Clean Architecture with Spring by Tom Hombergs @ Spring I/O 2019

Sdílet
Vložit
  • čas přidán 5. 09. 2024

Komentáře • 55

  • @ruixue6955
    @ruixue6955 Před 3 lety +19

    15:53 dependency inversion principle (DIP)
    16:11 left-side: database driven design
    16:17 Service has dependency on the persistence layer
    16:55 right-side: Entity is moved up into the domain layer
    17:09 Repository interface
    17:18 the persistence layer simply implement the repository interface
    17:38 meaning: we can choose the direction of any code dependency

  • @TJ-hs1qm
    @TJ-hs1qm Před 2 lety +3

    Single Responsibility Principle Lemma 🙂
    If a class fails in production there can be only 1 supervisor with a reason to fire you - say accounting. A class no longer conforms to the SRP if there are 2 or more - say accounting and legal.

  • @opusdei51
    @opusdei51 Před rokem +1

    If your layered architecture is database driven design, you are doing it wrong!
    I ALWAYS start with the user interface, derive APIs for each use case (screens, user interactions) and think about how to store the data most efficiently last.
    How on Earth can you define an optimal database design if you don't yet know exactly how the client behaves (what APIs will be called, which order & frequency)?

  • @vladimirljubopytnov5193
    @vladimirljubopytnov5193 Před 4 lety +8

    How is a set of concentric circles semantically different form top-down set of boxes :)? Both express ordering. Arrows can be drawn in both. You just can put more words to the outer ring.

    • @ranjithramachandran5928
      @ranjithramachandran5928 Před 4 lety +1

      I think there is a slight detail there what was missing from the slides. The direction of dependency is not the traditional way. Instead Everything external depends(gets generalized) inwards. blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

  • @moaxcp
    @moaxcp Před 2 lety +1

    The trick with using lombok to generate the constructor combined with the @Service annotation is awesome!

    • @GameOfLife55
      @GameOfLife55 Před rokem

      I still don't get how that works. Usually without Lombok you need to add the @Autowired annotation to the constructor to tell Spring to inject those fields but in this setup there is no @Autowired anywhere and Lombok is certainly agnostic of Spring so I can't think of it bringing it with it.

    • @alexsmart2612
      @alexsmart2612 Před rokem +1

      @@GameOfLife55 You don't need to add @Autowired annotation, and in fact you *should not* use @Autowired annotation. Look up spring field injection versus constructor injection.

  • @crabsynth3480
    @crabsynth3480 Před 4 lety +8

    Great presentation... good slides and concise explanations. I'm a spring newb and this definitely helped me to understand how to implement clean architecture with spring.

  • @douglasharley2440
    @douglasharley2440 Před 4 lety +19

    interesting...but i'm not sold. in my experience, the costs of building so many barriers to enforce isolation is far more expensive than changing things later on. that is, rarely (if ever) do backends change so much as to ripple throughout, but it takes lots of time to do all that mapping and duplication.

    • @ebichu8126
      @ebichu8126 Před 3 lety +9

      I guess the hexagon architecture is quite expensive to be built in the beginning for sure. However, I feel that this architecture would help a lot as the project is more and more complex, and more new guys are joining the project.
      If the project would stay small and complexity is manageable, I believe this approach is a kind of overkill.

    • @lievendoclo7478
      @lievendoclo7478 Před 3 lety +5

      @@ebichu8126 Now here's the kicker: how can you guarantee that a project would remain small with manageable complexity? If I had gotten a penny for everytime I've heard "Oh, but that'll just be a CRUD application", only to see them struggle 2 years later when the customer expands the scope... Clean architecture really doesn't add that much overhead compared to the net gains you get in the future. You're essentially paying it forward.

    • @ebichu8126
      @ebichu8126 Před 3 lety

      @@lievendoclo7478 Yeap, it depends on a contract with your client. if you don't need to maintain the product after building the app based on the contract, you don't need to bother to add fancy architecture in the app. However, if you have to maintain the app in the long run, it would be better to have clean architecture.

    • @lievendoclo7478
      @lievendoclo7478 Před 3 lety +2

      @@ebichu8126 In my opinion, software should be written as if you would have to support it. Or as some once said, as if you were writing for a psychopath who knows where you live. Customers tend to change their mind about that too, and then then you’re stuck with all the shortcuts you’ve made. Clean architecture adds *maybe* a couple percents of overhead when it comes to lines of code, but the ROI is incredible. It’s a false flag to say that the other way is cheaper, because it’s not. Not at the end. We need to stop justifying writing bad code.

    • @AndiRadyKurniawan
      @AndiRadyKurniawan Před 3 lety

      Also probably will take longer to design.

  • @steliomoiane494
    @steliomoiane494 Před rokem +1

    Congratulation Tom, that was an amazing session. I've learned so much.

  • @lytung1532
    @lytung1532 Před 11 měsíci

    My idea is that the use case should talk to domain service instead of talking directly to port. Each domain service will handle the business logic for each domain and it is the one that communicates with ports

  • @lucasmoreda7562
    @lucasmoreda7562 Před 4 lety +5

    Is this code example in github?

  • @zigzag2341
    @zigzag2341 Před 3 lety +3

    I think that ports usage is overengineering, and creating interface for each usecase too. Only worth idea is to split services into use cases, crud operations should be considered as one use case

    • @TristanOnGoogle
      @TristanOnGoogle Před rokem

      It's not though, because when your app becomes more complex, u may want to separate commands (write operations) and queries (read operations), where commands would be executed via ORM and queries would be native SQL queries using an other technology or even an other database (aggregated read model).

  • @NomadicBrian
    @NomadicBrian Před 2 lety +1

    I thought Java Spring Boot already had a small footprint for building applications. Was curious to see how the typical layers of controller, service, repository, persistence or JPA model would go. I've recently seen a .NET Core structure which has a domain, infrastructure and application tier. Have to say I'm not totally clear on business logic in the domain whilst micro-services are built in the application tier. My issues were that I had to know what the business requirement was and where we addressed it. How would I know how to implement it and send back a success or failure response in the form of a message.

  • @shakhawatstech9616
    @shakhawatstech9616 Před 5 lety +6

    I love hexagon this architecture

  • @dimitricharles9784
    @dimitricharles9784 Před 3 lety +1

    This is a great presentation. The only thing that is very debatable is putting the spring Service annotation in the use case service. And also the JsonCreator. As he said, it is his interpretation of the architecture.

    • @xutiTrinh
      @xutiTrinh Před 2 lety +2

      It is not debatable, you can create your own annotation to suit your need, it is understandable.
      But I don't really get the benefit of this structure with legacy MCV pattern, unless we need create more and more adapter to assume that our repository is not tied to JPA

    • @GameOfLife55
      @GameOfLife55 Před rokem +1

      @@xutiTrinh The benefit is that you abstract away the choice of technology from the business logic. So if you were to choose another repository implementation you can just add it with respect to the adapter contract. I don't agree with him having every persistence operation in its own adapter, just create one contract interface for all of them.
      That said, you have a point. In most cases, this pattern is extremely over engineering and brings with it a lot of overhead code related to mapping and redundancy. Especially if you use a Microservice architecture where you keep the Microservice's size relative small in terms of functionality then just go for the ol' good MVC.

  • @vadergrd
    @vadergrd Před 3 lety +1

    actually don't we have all these layers in each model?

  • @andiarbeit5468
    @andiarbeit5468 Před rokem

    The core should be independend of Frameworks. Why you use lombok in the Usecase?

    • @cansiparane6219
      @cansiparane6219 Před rokem +1

      Lombok just adds code to your class, no framework involved.

  • @kanalasgemkapocs
    @kanalasgemkapocs Před 4 lety +3

    I couldn't find the repo on GitHub. Could someone please help me?

    • @ThePitiYankee18
      @ThePitiYankee18 Před 4 lety

      github.com/thombergs/buckpal

    • @grzyboo9600
      @grzyboo9600 Před 4 lety +7

      @@ThePitiYankee18 Actually it's this one github.com/thombergs/clean-timetracker

  • @buckworthful
    @buckworthful Před 2 lety +1

    Would be good if code samples are shown

  • @matusseidl
    @matusseidl Před 3 lety

    Hi should I use one usecase interface per one "service" (usecase implementation), or can I use a lot of interfaces with one implementation? because I have one service with a lot of usecases and I think it isn't a good approach

    • @lievendoclo7478
      @lievendoclo7478 Před 3 lety +2

      To be honest, that's a detail, but I like the fact that I can just see from the folder structure what my use cases are. If you look at SOLID principles, interface segregation supports the idea of having a SAM interface for use cases.

  • @nguyenducthanh8907
    @nguyenducthanh8907 Před 2 lety

    Very clear, thanks so much

  •  Před 3 lety

    Great!

  • @qingcaish
    @qingcaish Před 4 lety +5

    just dont understand, but will come back latger

    • @JonesDTaylor
      @JonesDTaylor Před 4 lety

      czcams.com/video/keaTZ9M_U1A/video.html

    • @KENTOSI
      @KENTOSI Před 4 lety +2

      Yeah his coding examples were not great because they mixed too many unnecessary artefacts. He should've ripped out his "SelfValidating" interface, all his custom Spring annotations, etc and just focused on the Hexagonal components.
      It also got too distracting with the random pitches for the Spring framework.

    • @anthonyvella5308
      @anthonyvella5308 Před 4 lety

      @@JonesDTaylor Thanks this is gold

    • @StefanSchade721229
      @StefanSchade721229 Před 3 lety +1

      I guess it is hard to grasp from the presentation. I found the book "Get your hands dirty on clean architecture" helpfful

    • @jamilxt
      @jamilxt Před 2 lety

      @@KENTOSI any more resources you may suggest me? would be helpful. Thank you.

  • @ruixue6955
    @ruixue6955 Před 3 lety

    18:04 Clean Architecture

  • @therealtuyen
    @therealtuyen Před 2 lety

    How can we deal with a big problem with many use cases ?

    • @xutiTrinh
      @xutiTrinh Před 2 lety

      In this case, deal with your customer
      j/k.
      With many use cases combine then IMO it does not solve the complexity of structure, the purpose of hexagon is for developing isolation function at first but it is rare.
      You gonna mess (or mix) ton of such use case soon

    • @GameOfLife55
      @GameOfLife55 Před rokem

      Well, you try to divide that big problem with the many use cases in smaller ones with each a subset of those use cases.

  • @suikast420
    @suikast420 Před 3 lety

    Further hello world architecture.

  • @alexanderk3762
    @alexanderk3762 Před 3 lety

    am

  • @midclock
    @midclock Před 4 lety +5

    Very interesting topics...but please....a bit more of emphasis man!! Knowledge is a responsability....you cannot do a talk this important with so less energy. :/

  • @joachimdietl6737
    @joachimdietl6737 Před 4 lety +13

    Dont waste your time