The Combinatorial Explosion Trap: Does Your Code Have It?

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ธ.ค. 2024

ความคิดเห็น • 56

  • @zoran-horvat
    @zoran-horvat  2 หลายเดือนก่อน +3

    Learn more at Brilliant brilliant.org/ZoranHorvat/
    This link gives you a 30-day free trial and 20% off of an annual premium subscription.

  • @TayyabMughalDIK
    @TayyabMughalDIK 2 หลายเดือนก่อน +17

    An eye-opening for many. I would to love see your magic turning this anemic model to rich domain model

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +32

      @@TayyabMughalDIK I'm working on that. There will be a couple of videos covering that process, step by step.

    • @marklord7614
      @marklord7614 2 หลายเดือนก่อน +3

      @@zoran-horvat I agree that there's great value in learning how to tame such an anemic model.

    • @kaymeister634
      @kaymeister634 หลายเดือนก่อน +1

      @@zoran-horvat I'll definitely take a look at that. Thank you for sharing your knowledge with us

  • @pl4gueis
    @pl4gueis 2 หลายเดือนก่อน +11

    I've never seen this kind of explosion in the C# models because most legacy code I worked with have that combinational explosion at the database level. Usually hidden behind "status id" columns. Really glad you made some videos about how to properly design the models and persist them afterwards.
    I love that you show both sides. The bad design and how it evolves into the ball of muds they are and how to fix it or prevent it. Thank you for the videos.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +8

      @@pl4gueis It is true that we never actually see the combinatorial explosion in code. It is because programmers never make that step. However, the explosion remains in the state, hence long argument lists and thousands of failure modes per method, often not even covered by appropriate guard clauses.
      The overall result is an unstable application, which many programmers tolerate and consider "normal" in our profession.

  • @JonathanPeel
    @JonathanPeel 2 หลายเดือนก่อน +20

    This reminds me of “Make illegal state unrepresentable.”
    Excellent video. Thank you.

    • @user-tk2jy8xr8b
      @user-tk2jy8xr8b 20 วันที่ผ่านมา

      Too bad there are still no DUs in C#

    • @JonathanPeel
      @JonathanPeel 20 วันที่ผ่านมา

      @@user-tk2jy8xr8b When people want DUs that badly, why not use a functional first language?
      It is also possible to create an F# library to hold models (and DUs) and access it from your C# projects.

  • @lettuceturnipthebeets790
    @lettuceturnipthebeets790 2 หลายเดือนก่อน +4

    9:36
    "not the meaning of life you were looking for, I presume" 😂
    good one! love those bits of humor you throw into the educational stuff, makes it easier to digest, thank you ❤

  • @robertmrobo8954
    @robertmrobo8954 2 หลายเดือนก่อน +6

    Feel a bit criminal for this video to be released without a solution straight away. 🙂
    Falling in love with your content. ❤

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน

      @@robertmrobo8954 It will take a few more weeks to unfold the entire series.

  • @AH-wk1id
    @AH-wk1id 2 หลายเดือนก่อน

    Does anyone know a particular video or set of videos that shows how to fix the combinatorial explosion problem?

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +1

      @@AH-wk1id I am working on a few videos that will show that. In the meanwhile, you can refer to my recent videos about EF Core which are operating on the fixed version of this same object model.

  • @kristianaranda
    @kristianaranda 2 หลายเดือนก่อน

    ¡Gracias!

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +1

      Thank you! 🎉

  • @nickbarton3191
    @nickbarton3191 2 หลายเดือนก่อน +2

    I giggled all the way through this video.
    Awesome analysis.

  • @ibnfpv
    @ibnfpv 2 หลายเดือนก่อน +3

    Love this approach use it a lot with result objects not allow creating it by ctor only by a dedicated method that tells already the return state of that object this way it is guarded and readable

  • @Разни-н9л
    @Разни-н9л 2 หลายเดือนก่อน +2

    @zoran-horvat, I really appreciate the simplicity with which you explain complex concepts. Please consider creating a course on Domain-Driven Design and Clean Architecture.
    I’ve recently purchased a few courses, but after watching them, Clean Architecture and DDD seemed unnecessarily complicated and full of pointless abstractions. However, when I watch your videos, DDD feels logical and like something that truly improves our code significantly.
    Keep up the great work!

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +3

      @@Разни-н9л That's because before I apply DDD or Clean Architecture, I first strip them off of all the layers that don't add to simplicity and whose purpose is either not self evident or is evidently religious, and only then start with what was left.
      That is also why I am not making courses on either one of those. Many would say it is not DDD and it is not Clean Architecture to begin with.

  • @MohamedArafat1992
    @MohamedArafat1992 2 หลายเดือนก่อน

    thanks for all tutorials may i to ask something playlist isn't numbered and i don't know the proper sequence of videos can you number them please and thanks again

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +1

      I will make a playlist after I complete recording the series.

    • @MohamedArafat1992
      @MohamedArafat1992 2 หลายเดือนก่อน +1

      @@zoran-horvat thanks

  • @cristiz-vf4ww
    @cristiz-vf4ww 2 หลายเดือนก่อน

    Thanks!

  • @JanVerny
    @JanVerny 2 หลายเดือนก่อน +1

    The example here is great. And I genuinely agree that this is not a good way to model your data. But I think in most software you would never see this kind of combinatorial explosion. The reasons are A) most domain models are usually kind of small. And suffer from death by a thousand cuts rather than having one class with 10,000 lines. And B) in the bigger models people just give up on the guard rails. I worked on a huge corporate warehouse automation software and the lead developers basically solved this by making almost every column nullable and treating every combination as valid.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +5

      @@JanVerny I know what you're talking about. On the other hand, I think that the fact that programmers do not design proper models stems from them not being aware of what they are losing with that. There is very little truly powerful software over there, and it is nothing but a lost opportunity for everyone else.

  • @ShowoffFantasy
    @ShowoffFantasy 2 หลายเดือนก่อน +1

    That slapps in its own way, great job

  • @nikkollai
    @nikkollai 2 หลายเดือนก่อน

    Well! Ok, I see the issue, but it would be cool to see the solution to the anemic class issue. Looks like Zoran is recommending his other DDD videos to figure this out. Which other videos shed the light on the mechanisms to combat anemic class design.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +1

      @@nikkollai There will be more videos in this series that will cover the solutions, one at a time. On the other hand, most videos I made in the last several months are working on this same object model, and each is explaining one aspect of its design.

  • @Joey-m8w
    @Joey-m8w 2 หลายเดือนก่อน +2

    Love your content!

  • @elraito
    @elraito 2 หลายเดือนก่อน +3

    Awesome video .... but im sad because i make every mistake in video on regular basis. Do you have spyware in my computer?

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +2

      @@elraito Are you signed in to Google right now? :)

  • @guillermomazzari8320
    @guillermomazzari8320 2 หลายเดือนก่อน

    I truly enjoy your videos, they teach so much in such a short time and in a simple way, thank you very much for sharing your knowledge, I have a question, would a proper way to treat domain models be to consider them as database tables? Following the Normal Forms principal

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +1

      @@guillermomazzari8320 It depends on the project. If you are modeling a domain with a lot of business rules, then the data-centric approach is not good. You would probably need a solution where domain rules are central and dara are only the consequence. That explains the rise of higher-order languages and, especially, functional languages. They are simply better suited to business applications.

  • @alanis4AL
    @alanis4AL 2 หลายเดือนก่อน +1

    Awesome video

  • @poloolo69
    @poloolo69 2 หลายเดือนก่อน +1

    insane as always

  • @sVieira151
    @sVieira151 2 หลายเดือนก่อน +1

    Just one look at that initial Book class has my blood pressure rising 😩

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +2

      @@sVieira151 Yes, and it should.

  • @stevejohnny1111
    @stevejohnny1111 2 หลายเดือนก่อน +1

    I wish I had more of a clue wtf you are talking about sometimes, Zoran.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +2

      @@stevejohnny1111 Now what is that?
      But don't worry. This video is a part of a series. There will be more on this same topic and that should help you clarify it before end.

    • @stevejohnny1111
      @stevejohnny1111 2 หลายเดือนก่อน

      @@zoran-horvat The way you speak is like a riddle. It makes very little sense. I can usually follow the code to some degree but it's not made any easier by your commentary. You introduce a lot of terms that people won't know, in a strange way. I think you're a great programmer but could work on your teaching methods.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน

      @@stevejohnny1111 This channel is advanced, to begin with. It makes certain assumptions about its viewers. If you don't see sense in what I say that doesn't necessarily mean there is no sense.
      Connected issue is the programming terms you complain about. I never introduced a single programming term. Can you pinpoint the problem you observe starting from that?

    • @stevejohnny1111
      @stevejohnny1111 2 หลายเดือนก่อน

      @@zoran-horvat Yeah but the concepts you describe aren't overly complicated. Your language and strange delivery make it seem more complicated. You seem to think that you are telling some sort of story and that'll somehow make it easier to follow, however it has the opposite effect. It's not easy to pinpoint but I do think there is an issue with the language barrier as well because you are obviously not a native English speaker. This is evident in your written comments as well - you miss out key words. Whilst my brain will put them back in automatically, it's distracting. Example: " If you don't see sense in what I say that doesn't necessarily mean there is no sense. Connected issue is the programming terms you complain about" - you missed "A" before "Connected". You could have just said this: "Just because you couldn't make sense of what I said, it doesn't mean there is no value to it. This also applies to any programming terms you mentioned". My comment was not necessarily directed just at this video, but most of your videos. It's a shame because you have some really interesting thoughts, but your whimsical little stories and not very funny jokes do not add anything to your delivery. Oh and perhaps explain what the fuck an "anemic domain model" is. Anemia is to do with blood, not code.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน

      @@stevejohnny1111 No need to curse. You could have visited the Wikipedia page titled... let me check... "Anemic domain model." Well that is funny.

  • @aleksandarnaumovic3405
    @aleksandarnaumovic3405 2 หลายเดือนก่อน

    This way of coding could be also recognized as violation of SRP principle, from the traditional view point

    • @zoran-horvat
      @zoran-horvat  หลายเดือนก่อน

      The coding at the beginning or at the end of the demo?

    • @aleksandarnaumovic3405
      @aleksandarnaumovic3405 หลายเดือนก่อน

      @@zoran-horvat Of course, I think the anemic domain model violates SRP. Your variance with diferentiated classes is a better one, and makes a good separation of data, which is in accordance with SRP. Each single unit (class) is showing just that portion of data or type or class, thus making it cohesive within it's own concern.

  • @ShawnShaddock
    @ShawnShaddock 2 หลายเดือนก่อน

    The issues in this video are side effects of poor design choices and lack of language features like discriminated unions. It's wrong to blame an anemic domain model for these.

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน +1

      @@ShawnShaddock But you can use record types for discriminated unions now, so it's not the lack of a language feature I would use as an excuse. It is rather a lack of will to do something with the model. It is also preposterous to say that discriminated unions are THE solution, and then mention they are not supported out of the box, where the same effect is at hand's distance with a few interfaces and classes as well.

    • @vincentcifello4435
      @vincentcifello4435 2 หลายเดือนก่อน

      @@zoran-horvat How are you defining Anemic Doman Model? You mention Fowler who defines it as data without behavior. In that case, there is nothing about an Anemic Domain Model that necessitates these nullable or boolean status-type properties.
      One could argue that these problems are actually a function of the OOP mindset of encapsulated (mutable) state.
      Looking forward to your refactoring, as always.

  • @kantagara
    @kantagara 2 หลายเดือนก่อน

    Duša me je zabolela dok sam ovo gledao 🤣

    • @zoran-horvat
      @zoran-horvat  2 หลายเดือนก่อน

      @@kantagara Dešava se.