Implementing AggregateRoot, Entity, ValueObject | CA & DDD From Scratch Tutorial | Part 12

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

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

  • @GuigaPlay
    @GuigaPlay 2 года назад +38

    You're building a gold mine with this series. I can only imagine someone in the future finding this complete playlist and finally undestanding all these topics. Keep it up!

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

      so yea here i am!!!! hahah

    • @Lorin2286
      @Lorin2286 8 месяцев назад

      Hey! I'm someone from the future and indeed is pure gold :)
      Cheers!

  • @MilanJovanovicTech
    @MilanJovanovicTech 2 года назад +10

    Nice touch with Entity, and I wasn't aware of the notnull generic constraint 💯

  • @arthurfedotiew3609
    @arthurfedotiew3609 Год назад +19

    When you were talking about ValueObject concept in previous vids, I was thinking that your were gonna just use record type for this one property - Id. Now when you show how to implement it it is full blown class, so I wonder what are the benefits to go with class compared to record? Wouldn't record be much simpler and less boilerplate?

    • @DjicaOmoricic
      @DjicaOmoricic 7 месяцев назад

      this is exactly what i was thinking

  • @anthony2584
    @anthony2584 6 месяцев назад

    Hey, Amichai! Been watching your vids lately. I've been doing dotnet backend for 2 years now, but I'm primarily a NestJS/NodeJS backend developer. And I must say that your insights greatly gives me an outside perspective in me designing backend architecture, and it also inspires me to pursue to transition to Dotnet primarily (since your videos are making dotnet development cool!).
    I hope you could make videos (just hoping haha) regarding showing the advantages in setting up Models with your implentation versus to the basic setups in Models (without the AggregateRoot, Entity, ValueObject).
    And more power to you!!

  • @silvertek
    @silvertek 2 года назад +2

    Finally! Great video. You're such a tease with these quick vids, any chance you are going to do some longer format videos? Love your content, keep it up.

    • @amantinband
      @amantinband  2 года назад +1

      Hahah thanks silvertek. Some of the videos coming up will be longer 👍

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

    This video broke my brain but in a good way! Still a lot to learn! Thanks for the video!

  • @carmineos
    @carmineos 2 года назад +3

    Great video, I'm learning a lot from this series

  • @kmcdo
    @kmcdo 2 года назад +6

    keep the awesome videos coming! your videos are top notch! right up there with the likes of Chapsas!

  • @Yash42189
    @Yash42189 2 года назад +4

    Great tutorials man, thanks a lot

  • @szymonlisiecki4452
    @szymonlisiecki4452 11 месяцев назад +1

    6:04
    Suppose we want to use just a Guid as TId. Then, the Equals method would return true if any entities have the same Id, even if those entities were different. This approach forces you to use ValueObjects as an entity id. It's worth to keep that in mind

  • @acuencadev
    @acuencadev 2 года назад +1

    I love this series. Thanks for sharing your knowledge.💯

  • @subramaniannk4255
    @subramaniannk4255 4 месяца назад

    Loved the explanation!

  • @danil3700
    @danil3700 2 года назад +4

    Nice tutorial, but I have 3 questions:
    May we define our value objects like record?
    It would be better to define that the object id implements Iequatable, wouldn't it?
    (Question to the previous video) If we have an aggregate that has 2 large collections of entities inside, is it better to define them as aggregates too, despite the fact that they are not used anywhere else?

    • @amantinband
      @amantinband  2 года назад +6

      Thanks, Danil.
      1. Records for ValueObjects - Yes and no. Vladimir Khorikov has a good blog I would suggest reading: enterprisecraftsmanship.com/posts/csharp-records-value-objects/
      2. Yes. Actually, in our project, it would be better to put a constraint that the id implements ValueObject since that's the approach we'll take.
      3. As a rule of thumb - yes. Especially if you think about what happens with these large aggregates when multiple commands try to update the same aggregate simultaneously.

    • @danil3700
      @danil3700 2 года назад +1

      @@amantinband Thanks!)

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

      @@amantinband With regard to IEquatable, my understanding is that it is used to prevent boxing/casting to object. However,
      public bool Equals(ValueObejct? other)
      {
      return Equals((object?)other);
      }
      does exactly this. Therefore, any performance benefits that could have been made are now lost. Or, have I misunderstood something?
      Thanks. P.s. I'm enjoying all of videos 👍

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

      Didn't like the points about `Weight` and `with`.
      We can put validation in the set/init so that it can't be bypassed.
      And we can just implement another method for Equals with precision.

  • @mko3294
    @mko3294 4 месяца назад

    your are so amazing thank you :)

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

    Hey Amichai great series ! I have a question : in value object when defining == operator we use equals method that takes 2 arguments. But we never defined a method that takes 2 arguments inside that class. Does it take that method from somewhere else, or how does that work ? Thanks

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

      That's the magic of the operator keyword applied against ==, the lhs and rhs together make two parameters in total.

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

      And also we are overriding the equality operator since 'object' type which is the parent of all objects except primitive types has a default implementation for == which compares the objects by reference and we override it since we want to compare by value. Hope that helps.

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

      @@uzayrsyed6293 Hey thanks for the answer. It does help, but why in the == operator we use : return Equals(left, right) instead of return left.Equals(right)?

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

      @@fhwroungwnwget3705 When I look at the Object.cs metadata file the Equals method with two objects as parameters cannot be overridden. We are overriding the virtual Equals method with one object parameter and this is the logic we want to use for our == and != parameters. Seems like left.Equals(right) should be used unless Equals(left, right) uses left.Equals(right) internally

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

      @@uzayrsyed6293 My thoughts exactly. Thanks for clarification

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

    Shouldn't Entity have a constraint on type TId to be ValueObject?

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

    Thank you!

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

    Shalom, ahi ) I've seen in another video your AggregateRoot is using complex AggregateRootId - could you explain why?

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

    EDIT: NVM I realize that you are sealing the class the implements the abstract class.
    Should we implement IEquatable in a non sealed abstract class? Would it be better to implement IEqualityComparer instead?

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

    Hey Amichai, its been a while since yor last video in these series.
    waiting for domain validation and other greeate stuff

  • @ferci2865
    @ferci2865 4 месяца назад

    I want to ask why we don't use "!=" to check for null but instead use "is not null", what is the difference between these two ways of checking?

  • @sankarroychowdhury4655
    @sankarroychowdhury4655 6 месяцев назад

    I am using record for ValueObjects, instead of class. What kind of difficulties I may face for it?

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

    Am I missing some info here? Is this the final video of the series? I need to complete the app, there's a lot more to do here...

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

    @amantinband I am wondering why not use a record for the Value Object base class. I know this video is a year old, but still was wondering what your take, or anyones take on this is?

  • @Rob_III
    @Rob_III 2 года назад +2

    Am I missing something here? Why wouldn't you use a record here, that would give you all the equality stuff for free. But I have to confess I haven't watched the previous videos; this one just popped up in RUclips's suggestions.

    • @amantinband
      @amantinband  2 года назад +1

      Yes and no. Check out this blog post by Vladimir Khorikov where he shows some pros and cons enterprisecraftsmanship.com/posts/csharp-records-value-objects/

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

    How come this is part 12 but there’s only 7 vids in the playlist?

  • @Alex-w1v7k
    @Alex-w1v7k 2 месяца назад

    Why don't use Record for value objects?

  • @Dragonite594
    @Dragonite594 2 года назад +3

    first xD