DDD is just giving a $h!t about your Domain

Поділитися
Вставка
  • Опубліковано 19 лип 2023
  • When illustrating Domain Driven Design (DDD), sample/reference applications do more harm than good. Overall in a vacuum, they're a net negative. It isn't easy to convey the complexity and trade-offs made using trivial code examples. Beyond that, the code samples themselves are the wrong starting point.
    🔗 EventStoreDB
    eventsto.re/codeopinion
    🔔 Subscribe: / @codeopinion
    💥 Join this channel to get access to a private Discord Server and any source code in my videos.
    🔥 Join via Patreon
    / codeopinion
    ✔️ Join via UA-cam
    / @codeopinion
    📝 Blog: codeopinion.com
    👋 Twitter: / codeopinion
    ✨ LinkedIn: / dcomartin
    📧 Weekly Updates: mailchi.mp/63c7a0b3ff38/codeo...
    DDD Crew
    github.com/ddd-crew/ddd-start...
    #domaindrivendesign #softwaredesign #softwarearchitecture
  • Наука та технологія

КОМЕНТАРІ • 51

  • @Greenthum6
    @Greenthum6 Рік тому +13

    Sample application stack: .NET, serverless, event sourcing with CQRS, microservices architecture, integrated CI/CD pipeline, edge node globally hosted UI with Blazor WASM authenticated with Azure AD and styled with MudBlazor.
    The application & business domain: TodoList containing TodoItem, which has Name and IsChecked properties. Full feature list: Add/Update/Delete items

    • @flobuilds
      @flobuilds Рік тому +6

      In defense... If implemented correctly, it would propably scale to the moon 😂

    • @CodeOpinion
      @CodeOpinion  Рік тому

      Exactly.

    • @Greenthum6
      @Greenthum6 Рік тому +1

      @@flobuilds Yes, you must be prepared when the business folks require changing the database engine. AGAIN.

    • @flobuilds
      @flobuilds Рік тому

      @@Greenthum6 maybe a change to cassandra or scylladb ☠️

  • @justgame5508
    @justgame5508 Рік тому +8

    The issue with these examples is it’s virtually impossible to learn WHY things are dove a certain way in DDD without going through the issues they solve yourself. I tried to refactor our systems code base to a DDD vertical slice architecture, I made some good decisions, but their were times I was just lost. I didn’t know what the “proper” technique to use was. Eventually I settled in a middle ground between things that suited our needs and stayed in line with things I’d been reading up on. As we’ve added new features and learnt more about our system, the questions I didn’t have an answer to “why do it this way, why is so and so bad” become obvious. There is no way to genuinely learn this stuff without trying, failing, improving and trying again. Currently our system is screaming out for a event driven architecture approach, I was oblivious to this when we first planned it (wasn’t me actually was a dev who has since left) but now I’m find myself thinking “that solution would be so much more efficient and elegant with an event based system”. I’m sure I’ll fail, learn and improve plenty on this endeavour too

  • @drewjaqua2905
    @drewjaqua2905 10 місяців тому +2

    I watched this a while back or maybe I didn't and I'm thinking of one of your other videos, but I laughed out loud because I thought of all the "Building a TODO List: an introduction to domain driven development" tutorials I've seen out there. You hit the nail on the head when you said that sample projects do more harm than good.

    • @onistag
      @onistag 3 місяці тому +1

      No kidding! I was just thinking about the many todo list repos I've seen that are so insanely complex for NO reason but to show the pattern. It's such an awful way to learn patterns.

  • @brandonpearman9218
    @brandonpearman9218 Рік тому +19

    Agreed but I find that most developers want to choose a pattern and apply it everywhere regardless of complexity or use case for consistency. So if one model has extreme complexity but another doesnt, generally I see the implementation is done as both being domain models or none. most devs wouldnt have 1 domain and 1 script. Whats your opinion on that?

    • @CodeOpinion
      @CodeOpinion  Рік тому +9

      Ya, very much agree that's pretty common. I understand why because of varying degrees of experience and skill and often reasons why that happens. Force people down a road to conform to the "here's the way we do it" so there's going offside incorrectly. I get it. However, you can be making things more difficult in the long run because of it. Hence why I get comments about "I have to change 5 layers to make a single change" when something is purely CRUD.

    • @PaulSebastianM
      @PaulSebastianM Рік тому

      There are also degrees to patterns. For example you can use Value Objects and Entities but not Aggregates because maybe you prefer Transaction Scripts in maybe something like a service or right in your MVC API controller. That is not real DDD but some DDD patterns are hard not to see the urge to apply almost everywhere, especially in classic enterprise apps.

  • @nove1398
    @nove1398 Рік тому +2

    I like this explanation about the samples being too simplistic to properly demonstrate the concept that needs to be learned.

  • @aslkdjfzxcv9779
    @aslkdjfzxcv9779 Рік тому

    love your topics.
    AND i appreciate the simple thumbnails.

  • @bobbycrosby9765
    @bobbycrosby9765 Рік тому

    The maddening thing about toy examples is it's not hard to to think up domain complexity.
    Also, people writing an example could pick a domain they have some knowledge about and not handwave all the complexity away. I worked on a project a while back that was really good for this: it was a pretty small domain but the interactions were complex. So when I test things out I like to use that domain as a test bed of sorts.

  • @majormartintibor
    @majormartintibor Рік тому +2

    I can't even express how much I agree with you Derek. Perfectly put!

    • @majormartintibor
      @majormartintibor Рік тому

      oh and btw, that repo you looked at belongs to a coworker of mine. I am currently actively teasing him in our teams channel xD

    • @CodeOpinion
      @CodeOpinion  Рік тому +1

      It's not a bad thing as an author to go through those motions, but as an outsider with no context, just looking at the code, it can be for the reasons I outlined.

  • @JeffryGonzalezHt
    @JeffryGonzalezHt Рік тому +2

    A non-trivial part of my work is teaching, which is to say that I write "worthless" reference applications for a living. And I can't agree more. There is no suitable example, reference, or canonical domain model that is separate from the aggregated learning of the team that discovered/built it over the life of the application. Write tests, deliver stuff frequently, iterate. You will end up with your own special unique snowflake.

  • @MrDomenic123
    @MrDomenic123 Рік тому +2

    07:33 When you think your microphone has an issue and you replay that part two times, just so you can realize that Derek was farting on you 🤣🤣🤣

    • @CodeOpinion
      @CodeOpinion  Рік тому +6

      Figured it was a nice touch to add a fart.

  • @malismo
    @malismo Рік тому +1

    I think the biggest problem lies in terminology, it would have been better named Business Driven Design. You have to talk with and listen to business people and find out together, as you briefly mentioned, what processes drive the business and model those properly using the best DSL for each. IT is too stuck on patterns and best practices for its own good. It is called computer science, but I often experience it as computer religion. In my opinion, it should keep itself as far away from dogmatic practices as possible and has failed miserably at that the past decade. Sample code bases and preaching patterns are some of the root causes of that failure.
    Great videos, keep it up, you have a great way to explain difficult stuff in an easy to understand way, rare skill in our Industry.

  • @havokgames8297
    @havokgames8297 Рік тому

    Really good video. I totally agree. Now I would love to see someone attempt to teach the transition from transaction script to domain objects. I imagine it would take the length of a course instead of a single video to show, but finding the pieces that are shared between transaction scripts and making decisions about how to extract them into rich objects would be fantastic.

    • @CodeOpinion
      @CodeOpinion  Рік тому +1

      I've done something similar before but probably worth another video. Thanks for the suggestion

    • @robertmrobo8954
      @robertmrobo8954 Рік тому

      @@CodeOpinion
      Would be really happy if you choose any different system than Products, Orders or Warehouse. A totally different domain.

  • @matheussantiago203
    @matheussantiago203 Рік тому

    Hi! I really like your videos and I would love it if you could recommend me other channels that teach software design/architecture

  • @thedacian123
    @thedacian123 Рік тому

    Ok,so in order to have a good grasp about a domain we are addicted on business expoert,Are not we?,we can do without their help.
    And seconddly ,for the verry begining when we don't have any deep knowledges about the doain ,is it ok to start with the simplest Transaction script?!thank you!

  • @z0nx
    @z0nx Рік тому +1

    Derek, one of the things I believe many are struggling with, is getting a mental model of what application/domain/team is responsible for what event, and how these should interact. One way to get to that point is to collaborate, visualize and discuss. That's actually one of the things that tends to draw me to Event Modeling, are you familiar with this? Is there any other tooling that is your go-to for this kind of thing? I'm not yet familiar with EventStorming, but I keep hearing about it, so maybe it's better?
    The few times I've been able to do such an eventmodeling session, lots of input and discussion seem to come naturally to people, I really like that aspect.

    • @CodeOpinion
      @CodeOpinion  Рік тому +1

      I am familiar with Event Modeling. Event Storming is similar but different. Event Storming is more for collaborating for discovery, exploring the domain. Event Modeling is more about output for building the system.

  • @juanprosales
    @juanprosales Рік тому +1

    @CodeOpinion I like that you highlight that the key is to put the focus on understanding the domain before coding, but you also said that is not possible to explain concepts with a complex sample. I would love to see how would you explain DDD concepts, and not just saying when not to do it (just bc I saw you criticize the work of others a few times 😉)

    • @CodeOpinion
      @CodeOpinion  Рік тому +1

      Thanks for the comment. How would I explain DDD concepts? Well not in a 10 minute video 😂. But in aggregate you probably can get the gist from a pile of videos I've published. The tactical patterns are a means to an end and aren't required at all. For example, in a functional lang you aren't creating object models as domain models. If I were spending time explaining it, in length, it would be more in depth to each parts of the last diagram I showed and how the iterations are important.

    • @juanprosales
      @juanprosales Рік тому

      ​@@CodeOpinion and after I commented I saw this video of yours which I think it's really great (ua-cam.com/video/PrJIMTZsbDw/v-deo.html) that you published before becoming a reference-app killer 😋. Just kiding, only wanted to say that ref apps are not bad if we are aware they are over simplified demostrations of how to estructure the code, that we can apply it when we have a complex domain.

  • @kirillhorn3186
    @kirillhorn3186 Рік тому +2

    Almost in every video you mention transaction script, could someone explain me what it actually is. I was doing DDD, I was thinking so, but in most cases it's just a wrapper above setter.

    • @m4r10x2
      @m4r10x2 Рік тому +2

      An example of the transaction script is when you inject DbContext, do some business stuff in the method, in the same method you update DB and at the end you call _db.SaveChanges(). There is no domain objects, you usually work with your DB entities directly, update the state, and save them into the DB.

    • @kirillhorn3186
      @kirillhorn3186 Рік тому

      @@m4r10x2 thanks a lot!

  • @dlcardozo
    @dlcardozo Рік тому +1

    The code should be an asset at the end of the understanding of the problem to solve. When you start from the code you missed all about DDD. And TRY HARD to have a common language between all the people involved in solving that problem, that language should be on each line of code. The code will change, be ready for that, because the domain model (the problem) will change iteration after iteration.

  • @marcusmaunula5018
    @marcusmaunula5018 Рік тому

    But what open source projects that are not samples as good study points? Do you have any such examples :)

    • @CodeOpinion
      @CodeOpinion  Рік тому +1

      That's the problem. There aren't any that I'm aware of.

    • @marcusmaunula5018
      @marcusmaunula5018 Рік тому

      @@CodeOpinion Worth a shot ;).

    • @GackFinder
      @GackFinder 10 місяців тому

      I would bet all really good examples are highly protected corporate secrets because they probably generate a lot of money. No way anything truly good would be just freely available. Good stuff costs money.

  • @piromanaBG
    @piromanaBG Рік тому

    Completely agree

  • @yakovkemer5062
    @yakovkemer5062 Рік тому +1

    I think model is overcomplicated. It should be done either with validator, or validation attributes.

  • @Mike-rt2vp
    @Mike-rt2vp 9 місяців тому

    "... You should start caring." Right into ad read, lol. No disrespect just thought it was funny.

  • @AkosLukacs42
    @AkosLukacs42 Рік тому +1

    Yepp, DDD is not a coding pattern!

    • @manrikevillalobos6270
      @manrikevillalobos6270 Рік тому

      Finally someone said it!! Completely agree, and that is one of the main reasons of bad DDD coding examples out there, and DDD being really misunderstood... and abused. DDD is not a coding pattern, neither an architecture!! It's a guide to model a business... my God!!

  • @marna_li
    @marna_li Рік тому +2

    Reference projects are built by technical people who care about the implementation details before the process of understanding what they are building. I think we are all guilty of doing this at some point.
    I have tried to make a reference project that shows the details, but you always end up with some simple scenario that doesn't illustrate more than the concepts in code. Concepts that are hard to grasp without the context.
    And they are misleading people who are looking for samples on how to implement code "DDD"-style. Not even telling them about the tradeoffs that they have to make.
    Not every developer is as passionate about programming and learning new things. Seeing everything from a technical lens is not gonna sell if you are in a team. There are people who just want to do their jobs.

    • @CodeOpinion
      @CodeOpinion  Рік тому

      Yup. Why I included "in a vacuum" they are a net negative because as you mentioned they don't illustrate trade-offs or often the "why" something is being done because the examples are so trivial. They have to be trivial to get the gist across because nobody wants to spend days to grok some all the domain complexity.

    • @CesarDemi81
      @CesarDemi81 Рік тому

      I think they are mostly to get you a structure to get started with, but not a full prescription on how things need to be done. My opinion is that it's more about getting the boilerplate part done with something that might more closely ressemble what you're trying to achieve rather than them being a fully closed prescription on how things need to be done.

  • @awright18
    @awright18 Рік тому +1

    This may be the best title for a video that you've ever created!

  • @feitan8745
    @feitan8745 Рік тому

    Most of the samples are not helping at all, because when we really to use these, it's in a much bigger scale and in a more complex scenario.

  • @danielgilleland8611
    @danielgilleland8611 Рік тому

    S.A.M.P.L.E - Simple And Mediocre Problem Learning Exercise
    ;)