Domain Modeling Gone Wrong - Part 1

Поділитися
Вставка
  • Опубліковано 21 гру 2024

КОМЕНТАРІ • 71

  • @xDedMopdex
    @xDedMopdex Рік тому +11

    Looking forward for next chapter. Trying to re-arrange models in my project using your tips from another video about Aggregate Roots, but still finding it's complex, especially when you need to befriend custom aggregates with EF tracker.

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

    Danke!

  • @Galakyllz
    @Galakyllz Рік тому +3

    I had to pause the video at 0:50 to say how much I love these diagrams. This is a wonder representation of how these things are structured.

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

    I have learnt so much from you, and this, yet again is no exception. I was struggling with this when I first watched his videos but I couldn't vocalise it as well as you have here. I think most of your videos boil down to 2 concepts (with the rest being nuance), coupling and behaviour. I have even gone one step further and created a "code generator", don't judge, that builds code stubs and scaffold using behaviours to ensure the team doesn't fall back into the structure traps. So far it proving VERY useful.

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

    Event Storming helps with identifying events, and behaviours happening in the problem domain. From there you can form the domain boundaries and then aggregates. It is an iterative process and does not come from a first insight. Keep discussing the domain concepts with the business eventually it will become obvious what is what. If you have any workflows, state machines, they are usually about the aggregates.

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

    I'm really excited to see your next chapter, and if it's possible, could you consider creating another series about ERP systems, eh?

  • @alexiosplomaritis9713
    @alexiosplomaritis9713 Рік тому +3

    Great video, thank you Derek :) Modeling is probably one of the most `glanced over` parts of software design and this video provides a great way to think about it.

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

      Plan on expanding this as mentioned with some future videos to give some more insights on how defining the capabilities influences the underlying data and how it's organized.

    • @markop.6159
      @markop.6159 Рік тому +2

      @@CodeOpinion Every thought about making a whole course where you show how you would solve a non-trivial real-world problem?

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

    Please 🙏 do it. Your approach is completely pragmatic. Behaviour is the 'Boss', I could of late able to extract huge a amount of positives out of targeting behaviour than the internals. I was given a huge module at work to rewrite, and I can tell you that I have done it successfully only by aligning my units right ( driving my tests using outside-in )

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

    ... and on top of that, if you follow the code in the mentioned example, those GUIDs won't match when creating the Entity and during persistence, can't wait for the follow up vid, modelling is hard for sure. thanks for sharing

  • @andersjuul8310
    @andersjuul8310 8 місяців тому

    Ah! Juat saw this again. As an old geezer, I was taught to do OOD by identifying entities. I needed to hear this. Thanks!!!

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

    I’ve always struggled with aggregate boundaries, the original example referenced helped me a lot, so I’m really looking forward to your behaviour driven approach to define the boundaries with reduced coupling which I have also struggled with!

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

    Very curious to see your approach in Amichai's scenario. I completely understand your focus on behavior instead of data structure, but feel myself more lost on implentation. Defining data structures like Amichai drives you to a straightforward implementation, so looking forward your next video to comprenhend how you define your scenario.

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

      The question to ask is how did you arrive to where you are? Workflows and processes are what drive business. If you're have an object model hierarchy (normalized database schema really), the workflows and processes live in your end users heads, and they execute those on top of your system. Your system doesn't know about them. You'll end up with primarily a CRUD driven system. This is tricky because sometimes you can try and force behaviors where they just don't exist. Example is CreateMenu, AddMenuItem. Is that bad? Depends on what a "Menu" means in your system. "CreateDinner", "UpdateDinner" when your a dinner hosting platform smells off. You're hosting a dinner, making reservations, etc. What's the value in focusing on behaviors (where appropriate)? If you're capturing intent you can then open up the doors to exposing what's happened in your system (events). This leads to the rabbit hole of EDA.

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

      ​@@CodeOpinion Totally agree with you. Years of experience in CRUD driven systems have taught me the difficulties of adding new functionalities as the system grows. Coincidence or not, both Amichai and you uploaded a new video just after my comment. Thanks a lot for your insights

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

    Awesome!
    I really like the pragmatic way of your designs.

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

    This is a great video Derek. The issue I unfortunately run into in the corporate world. Since I'm not the architect I never get to implement these patterns and am told 'thats not your job as a dev leave the decision making to the architect'.

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

      Yikes. IMO everyone on a small team can be involved in the design and architecture. That doesn't mean decision making but at least being apart of the understanding of why and all the trade-offs being made.

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

      Devs are in short supply, if you are a good dev just leave. No need to put up with that because there are companies which will respect your role as a dev. But also be cautious when trying new patterns that you dont have experience with because they often look good and easy in youtube videos but then become a nightmare in practice.

  • @marcom.
    @marcom. Рік тому

    Will be interesting to watch your next video. So far, the concept of an aggregate has been helpful to me, especially in the context of the persistence layer. I have created aggregates to determine which subtree of my domain model should be loaded together into a persistence context, modified and saved again. So it's a very transactional view. I understand your approach to pay more attention to the behaviour of a system, but in the end, the resulting transactions must somehow fit the relation model of the ORM.

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

    Having worked with enterprise software for a few decades, at the end of the day - in that world - what everyone cares about is the data.
    The software on top might change, the UI might change, the flow of data between systems change. But the data is the important thingy.
    You want to be able to write it somewhere, and retrieve it at some time in the future.
    I think we developers have a bit too much emphasis on the software, because that's what dear to us. But it isn't really that important.
    Nobody really cares how you do things, as long as your software solves the user's problems, is fast, secure, without bugs, and you can add features quickly.

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

      Agree'd, however the data you capture is dependent on what users are trying to accomplish, even if it's CRUD. There's workflow and processes in their heads even when using CRUD or excel. The data doesn't come from thin air randomly for no reason. That's my point. You don't have to capture intent everywhere, some places can purely be CRUD. And in those places.. use CRUD. In places where theres a lot of complexity in your software, you need to understand the workflow because the data behind that, as you mentioned, is important.

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

      @@CodeOpinion - yes, I always ask what data is to be captured, and why. Asking people to input data for the fun of it is never a good idea. At the end if the day the important data will be used for something else somewhere.

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

    Would really help to have that next video as it is a bit hard to digest seeing only the wrong way to create a domain model. I can definitely see the model looks awkward right from the start, but still trying to wrap my head around it, because I don't know the full context of the application. My thoughts are though, why would a Menu have behaviors? A menu should be decoupled from whatever is using it, correct?

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

    How do I make DDD simple for the junior devs on my team? The terminology is difficult for me to grok let alone someone entirely new to the field.

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

    I would say that the "behavior" is tightly dependant on a business needs, process, rules and boundaries which this "behavior" is supposed to implement, that is why it is very important to understand the business area, i.e. the context. Without deep understading if all business aspects most of the "behaviors" became simple transaction scripts.

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

    Very interested to see your approach to the task. It'd be pretty cool if all the prominent UA-camrs were to tackle the same domain problem. Everyone could learn new approaches and strengths and weaknesses of the designs clearly.

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

      The problem is all examples are simplified and made up with little complexity, which isn't what most projects/products are like.

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

      @@CodeOpinion thats so true

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

    If we're talking about DDD, the problem is with most of the books or resources, that they are too abstract. That is mostly from what I've seen. DDD is hard entry barrier for not only beginners but also more senior developers since books don't provide many in-code examples. Recently, I have been reading a DDD good book by Vladik Khononov, and that one breaks that tendency a bit, which I find personally great.

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

      I've mentioned this a bunch, but for anyone reading again, the issue is providing a context with enough domain complexity to warrant it. Nobody is going to sit through hours of explanation of a complex domain. You have to be abstract enough and the reader/viewer has to hopefully fill in the blanks (correctly) about what "complexity" actually is. Unfortunately, that doesn't seem to happen and patterns/practices are used when it's not justified.

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

      I should have rather used “concrete” than in-code, in the afterthought. But, Stack overflow is filled with basic questions on DDD and not even the complex bits. One of the common complains I hear related to DDD is that “no one knows how to implement this right” which is recurring. For me personally, if I had to start learning it anew from scratch, it would help to sit through an elaborate example of complex domain in form of a workshop or something alike, since it can alleviate most, if not all the questions in a single session.

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

    I'm really looking forward to learn, how you would design the system

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

    The problem starts with jumping straight to aggregates before you've worked with the business to understand the actions and events of your system. You can't understand your service boundaries, much less your aggregates, until you have worked out the process and events with the business.

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

    Amichai Mantinband's videos are really focused on defining data structures and not primarily modeling entities with their behavior. Entity here is just a fancy word for an instance of a data class. Why even mention the Id:s? They are an implementation detail and not necessarily part of the model. I know how easy it is as a programmer to jump on implementing something. But the point of DDD is to figure out what to build - and not structuring your code.

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

      Understanding the domain and modeling that in code as relatable as possible. There will always be technicalities in code but more often then not theres not a single model or a single representation that servers all purposes. This wasn't a review so much of that video as using it as inspiration for my own of what I wanted to illustrate.

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

      @@CodeOpinion Sure. I know that. And these were just my immediate thoughts when you mentioned it. I do however think that context is important while modeling. And to keep it balanced. Your model is a representation and don’t let the technical details distract you. Which often happens in these examples.

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

      @@marna_li So many toy examples leave out technical details to the point of uselessness. I'd rather see too many details than not enough. Furthermore, leaving off details can make the design appear cleaner than it actually is once you go to implement it.
      For example, one thing I really do like about this channel is he mentions technical concerns like consistency, whereas so many examples just completely ignore it.

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

      @@bobbycrosby9765 I meant that it focus a lot on how it is being implemented rather than how to approach software development in terms of organising and finding a structure that lets the project and codebase evolve.
      Yeah. Consistency and such is seldom taked about in other channels. It is quickly skipped over and taken for granted. I guess the point is that other samples are not complex enough.
      But to understand stuff, perhaps more in-depth technical examples are great. Not just as part of some mega reference project.

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

    Yes, agree with you, that's the way, indeed. Great video. Thanks

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

    Funny I don’t know anything about DDD but I wanted to comment that you should start the design from the actions you want to be able to get or do as a user until he said it himself.

  • @noaml-1
    @noaml-1 Рік тому

    When you say behaviors, I guess you mean application commands (like in CQRS). Right?

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

      Commands, Actions, Workflows, Intent.

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

    This seems like it's going to create tons of technical debt and will pull on the proverbial string when the behaviors/actions inevitably need to be modified or are simply deleted because a process is no longer needed.

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

    looking forward for the follow up

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

    Is a "User" really an entity? I often question things like this because the concept of a "user" is not actually part of the problem domain, but something that came into existence when we are trying to automate the solution. Just a curiosity, great video as usual!

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

      It depends. If you can swap out all the attributes on a user with another user and they can be treated equal then it's not an entity.

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

    Good topic with continuation. It is the best way to make people(at least me) to subscribe. Thanks!

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

      If you watch enough of my videos, you'll notice an underlying thread (continuation). They all relatively relate to each other in the grand scheme of things.

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

      @@CodeOpinion yes I noticed, but this feels like good seial episode which finished on the best part :)

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

    so what book is the top one - the bottom one I have :D

  • @appstratum9747
    @appstratum9747 Рік тому +3

    Good video. Again.
    Jeez, Derek, the high quality of your content is getting oh-so-monotonous.... 😀
    Yup...understanding the transactional / consistency boundaries in your system is driven by understanding the behaviours within your system that require consistency to be maintained. And then starting to think about Aggregate Roots.
    On the other hand, beginning with your domain objects and data structures rather than behaviours will have you scratching your head pretty quickly in anything other than the most simple systems. At some point a new behaviour will come along that will have you jumping through hoops with your domain model. And probably refactoring regularly as you discover the cascade of unintended complexities that you may have introduced by starting from the wrong place.
    And then comes the the *next* behaviour that has you doing the same thing all over again (but this time with possibly even more complexity and hoops to jump though) until you realise that starting with behaviours first was the best way to go right from the start.
    I look forward to your follow-on video!

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

      Thanks. A lot of what I was describing is one step farther from "entity services", which is why things become highly coupled. If you have the concept of entity that exists solely exists in one aggregate, you then need to reference that aggregate because it contains all the data for everything "related" to it.

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

      @@CodeOpinion Indeed.

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

    thanks

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

    Nice to see Amichai's perspective being challenged. I knew something was off from the get-go.

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

      I wouldn't view it that way really. I don't. It's more of taking the example used and elaborating on it.

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

    Great video. I'm looking forward to the follow-up video.

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

    7:37 Create a video? That's pretty CRUDdy

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

      CRUDy in areas, Task driven in others.

  • @felixnotthecat4249
    @felixnotthecat4249 2 місяці тому

    BubberDinner

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

    In summary, do TDD/BDD.

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

      Somewhat. Build your entities based on behaviors and the data required for those behaviors, not the other way around.