Writing cleaner code with Domain Driven Design by Paul van der Slot

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024
  • I always thought that my code was fine. I took my time for naming things, wrote small classes/methods and tried to use other Clean Code practices. But after a job interview with a technical coach, I was pointed towards Domain-Driven Design (DDD) and some other design topics. I could learn a lot from it, said the technical coach. And I did! Since then, I started noticing how much parts of DDD could help with my day to day job. I will take you with me on my learning journey of Domain-Driven Design, and how it helped me improve my code. We will touch upon themes like Ubiquitous Language, Supple Design, Bounded Contexts and more. You can expect a talk with a lot of code examples and practical advise that you can use the next day.

Комментарии • 33

  • @mirageman2
    @mirageman2 Год назад +34

    Great talk, thanks. Maybe you could do a part 2 where you show more code examples of multiple bounded contexts interacting with each other.

  • @DomainDrivenDavid
    @DomainDrivenDavid Год назад +2

    Very good, thank you! I am in the staring phase of understanding DDD and clean architecture, and I am implementing this on the next professional application I am working on!

  • @surendardashinamurthy2154
    @surendardashinamurthy2154 Год назад +2

    A clear and crispy talk. Much appreciated

  • @rodelias9378
    @rodelias9378 Год назад +4

    Awesome talk!! Really well-explained and well-paced. Thx a lot!

  • @OscarAgreda
    @OscarAgreda День назад

    Thank you . Your emphasis on concepts like Ubiquitous Language and Bounded Contexts is particularly valuable. One question I had: How might we balance the trade-offs between the flexibility of microservices and the structured approach of DDD in a rapidly evolving business environment?

  • @Personal-M.I.S.
    @Personal-M.I.S. Год назад +3

    This is good stuff! I've been trying to wrap my head around DDD for a while and some of this has really clicked. Skoal!

  • @bobslave7063
    @bobslave7063 9 месяцев назад +1

    Amazing lecture, thanks.

  • @Pest87
    @Pest87 Год назад +1

    This is a really great lecture

  • @thomas.moerman
    @thomas.moerman Год назад +19

    I would recommend against the use of derogatory of terms like "Primitive obsession" like it's some kind of accepted truth that using primitives is bad practice. It's not. For instance, there are a ton of cons to the "Wrapper obsession" remedy you propose: code bloat, superfluous indirection, the "private language" problem that DDD using OO typically suffers from.... There are always trade-offs.

    • @paulvfc
      @paulvfc Год назад +8

      Indeed Thomas, there are always tradeoffs. I would recommend agains using wrappers for everything. Some Strings that need validation and have some business logic are perfect cases in my opinion. Think about an IBAN (validated), and which you might ask the country code (substring).
      But wrapping a firstName in another object is not something I do. No validation needed, no extra logic, just code bloat.

    • @thomas.moerman
      @thomas.moerman Год назад +3

      @@paulvfc I understand your point. Given a typical OO language like Java it is a reasonable approach. Other languages offer different possibilities for the example you describe. For instance what I typically do: leave the email-address as a string, but instrument functions (at the contextual boundaries or where-ever you like) with spec validation that can be turned on/off using a flag, depending on the deployment env. This approach doesn't seem like a big improvement at first sight but *dramatically* simplifies nested data-structures that pass through domain functions. Plus the significant advantage that I can use whatever functions my language offers to manipulate Lists, Maps, Vectors, Strings and other primitive scalars to manipulate the data structures while they pass through my domain functions, leading to much less code. The shape and type of these structures are spec'ed in the appropriate time and place, enabling a leaner approach and more opportunities for generic function design because there are no "private domain language" classes to take into account. Check out Rich Hickey's talks for a more elaborate perspective on this matter.

  • @kiranbhanushali7069
    @kiranbhanushali7069 Год назад +1

    Great Talk, Helpful.

  • @chadlooker4657
    @chadlooker4657 9 месяцев назад

    An "anemic domain-model" sounds more intuitive given that we write data-processing programs. The data outside the program is inert, e.g. the JSON you get over the wire or your row in the database doesn't have behavior. It makes more sense to me to model the data as data, and place what you do with the data somewhere else.

  • @LarrySmith1437
    @LarrySmith1437 Год назад +4

    I'm interested in the following: once you decided that Employee is represented almost independently inside various bounded contexts, how can you later find out about an "Employee" ACROSS the bounded contexts? I get that they're different representations in each context but it still feels like in some situations there could be an implicit relationship of an entity across the contexts.

    • @paulvfc
      @paulvfc Год назад +1

      Good question. I would say an employee originates from one context. Maybe the HR context where a candidate becomes an employee after signing a contract. After that an event could be fired like 'Employee hired'. Other contexts could listen to that and use the same Employee id(as a reference) to create a consultant for instance in the sales context.
      If you want to have an overview of everything related to that employee you could group information of different bounded contexts, using the shared employee id.

    • @LarrySmith1437
      @LarrySmith1437 Год назад

      @@paulvfc I like that answer it makes sense there would be one authoritative demand that others could key off of and I also like the thought about using Events the other domains can listen to if they want to do something about their version of employee

    • @sebastianpopa4778
      @sebastianpopa4778 Год назад +1

      my 2 cents. An "employee" does not really exist "across" bounded contexts. If it does, is mostly by mistake or by some misfortunate language representation. So in the example with "employee" and "consultant", it becomes obvious that there has to be some aggregation of "pieces" ("employee", "consultant") which lives outside of these bounded contexts and (forcefully) puts the pieces together. Often these are just "reports", and since they are rather technical than business, not sure makes much sense to think of them as "bounded contexts" (maybe as support business context). As some others commented, there should be another talk (Paul? ;) ) reg. communication and translations (or not) between bounded contexts.

  • @sandeeppandey1506
    @sandeeppandey1506 Год назад +1

    Great Talk !!

  • @gamingindustry6312
    @gamingindustry6312 Год назад +1

    merci beaucoup a toi :))

  • @stIncMale
    @stIncMale Год назад +12

    22:19 "tell, don't ask" - it's irritating when people keep coming with weird names for ideas that already have a name (I understand that this name was not invented by the speaker). This one, for example, is called "encapsulation".

    • @khajalieubarrie5088
      @khajalieubarrie5088 Год назад +1

      I think there’s a deliberate reason cause if someone think they already know encapsulation and you tell them to always favour it in domain driven design, it can mean different thing to different people.

    • @LarrySmith1437
      @LarrySmith1437 Год назад

      @@khajalieubarrie5088 That... is so meta. The ubiquitous language of programming itself.

    • @mihaiapostol7864
      @mihaiapostol7864 11 месяцев назад +2

      for me this phrasing represents "intentional" encapsulation. usually when you're taught about encapsulation you're only taught about getters and setters. the concept of "tell don't ask" goes further

  • @LittleLightCZ
    @LittleLightCZ 7 месяцев назад +1

    👏👏👏

  • @johnathanwaters5448
    @johnathanwaters5448 Год назад +4

    I may be misunderstanding, but is this basically a way to use ideas from functional programming in object oriented implementations, via the use of typing?

    • @khajalieubarrie5088
      @khajalieubarrie5088 Год назад +3

      Domain Driven Design is agnostic to a programming paradigm. It’s more of a design approach I believe. To take your problems and solution from the Enterprise world to software world. However, Object Oriented Design aligns with arguably all of its construct.

  • @user-sg4kw8uh3m
    @user-sg4kw8uh3m Год назад +1

    Thanks

  • @wazum
    @wazum Год назад +5

    Hm, there are multiple things wrong in this talk, e.g. Validation and Transformation in the (MongoDB) repository? Definitely not the right place for that.

    • @BuriTechVids
      @BuriTechVids Год назад

      It depends how you perceive those terms. For example when you're using Doctrine/Hibernate library in infrastructure on the side of repositories, there's always some validation and transformation into domain objects. Or for example we are checking tenant id in multi-tenant application for each received object even it's already handled by database itself. Just to be sure/to double-check that we're not receiving what we shouldn't receive.

    • @Emerald214
      @Emerald214 Год назад

      Agreed. The repository has a dependency on DTOs such as Card, which is weird. Secondly, sometimes the validation depends on other entities. A single repository can't validation and transformation alone.

  • @nichtverstehen2045
    @nichtverstehen2045 20 дней назад

    meaningless stream of buzzwords

  • @luisdanielmesa
    @luisdanielmesa Год назад

    Hexagonal Architecture is dead and he doesn't know it. Hexagonal is a type of BCE, BCE is still king.

  • @purpinkn
    @purpinkn Год назад

    Wtf is he talking about