Factory, Abstract Factory, Factory Method - Design Pattern (C#)

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024
  • Explanation & Examples for the Factory, Abstract Factory and Factory Method design patterns.
    Patreon 🤝 / raw_coding
    Courses 📚 learning.raw-c...
    Shop 🛒 shop.raw-codin...
    Discord 💬 / discord
    Twitter 📣 / anton_t0shik
    Twitch 🎥 / raw_coding
    👉 Try Rider
    www.jetbrains....
    RD5K9-4TXXW-KMV3G-NYWSF-3ZSTP
    Playlist: • c# design patterns
    Source: github.com/raw...
    #csharp #designpattern #factory

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

  • @sebad_informatica5696
    @sebad_informatica5696 3 года назад +15

    Hi @Raw Coding, at 4:29 you say "this concept is also known as Dependency Inversion" but wouldn't the concept actually be "Inversion of Control (IoC)"? This last one by means of "Dependency Inyection" of the factory. Because if I understand correctly "Dependency Inversion" would be the "D" of SOLID principles and the intent is different, which in the later case would be decoupling. Am I right? Regards

    • @RawCoding
      @RawCoding  3 года назад +4

      You are correct, thank you for letting me know I wasn’t aware of the fine grained difference between DI, DIP and IoC. I always bunched them up together.
      martinfowler.com/articles/dipInTheWild.html#HowDidIGetHere

    • @andreikashin
      @andreikashin 2 года назад +7

      try no to stick to bla-bla terminology.

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

      @@RawCoding Thank you very much. Long search ended here....so much of wrong info out there in this regard.

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

    Very simple demo and i love it when you explain when/where to use this pattern. Thank you and appreciated! 💙

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

      Cheers! Make sure to check out the playlist

  • @RANVEER.4321
    @RANVEER.4321 2 года назад +4

    Thank you so much... 9 mins.. and I learned it. I have seen many long videos. But nothing compared to this..

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

    Bro, the series of videos explained design pattern the easiest way, thank you so much

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

      Glad you enjoyed them bro )

  • @AlexxXRecorD
    @AlexxXRecorD 2 года назад +5

    The best explaning, I've ever seen. Thanks!

  • @pereirao
    @pereirao 3 года назад +1

    Are you a psychic?
    Yesterday I was looking for more information on abstract factory pattern.
    YESTERDAY! Less than 12 hours ago!
    Anyway, thank you and greetings from Brazil! ^_-

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

    Liked your background, not distracting at all ;-)

  • @amirh.jabari5401
    @amirh.jabari5401 3 года назад +6

    Yohoo... I'm going to love this play list😍😍

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

    Hey man! I really appreciate your channel and the way you explain the concepts. I hope everything is ok with you. Your last video was one year ago. Big hugs!

    • @RawCoding
      @RawCoding  2 года назад

      Cheers my dud all is good, I still upload videos

  • @kapilgupta4409
    @kapilgupta4409 3 года назад +4

    Amazing ! You are an outstanding developer.

  • @RawCoding
    @RawCoding  3 года назад +6

    Books I'm holding at the end (thinking that ending clip might get boring quickly)
    .NET Pro Memory Management
    Design Patterns (GoF)
    Structure and Interpretation of Computer Programs
    The Joy of Clojure

  • @saurabhchauhan232
    @saurabhchauhan232 3 года назад +3

    Thank you ! Finally Design pattern started,

  • @mahmoudalaskalany
    @mahmoudalaskalany 3 года назад +1

    i have passed this situation where i have to generate form controls from backend and am using factory pattern for it
    its very good for this use case
    thanks for confirming it Anton

    • @RawCoding
      @RawCoding  3 года назад +1

      Thank you for watching

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

    thank you for the simple explanation :]

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

      Thank you for watching )

  • @adwers-comdamiannass4561
    @adwers-comdamiannass4561 2 года назад

    Beautiful explanation, just Beautiful❤. Thank You👏

  • @domantasg7660
    @domantasg7660 3 года назад +8

    Could you please make series about Domain-Driven-Design. And how a project would scale and look like when applying this practice?

    • @RawCoding
      @RawCoding  3 года назад

      Don’t really do DDD

    • @hadibazmi6340
      @hadibazmi6340 3 года назад +1

      @@RawCoding are you a functional guy rather than ood maniac?

    • @RawCoding
      @RawCoding  3 года назад +1

      Yes, I prefer functions )

    • @hadibazmi6340
      @hadibazmi6340 3 года назад

      @@RawCoding i kinda sense that
      Maybe later discuss that too
      I try to be more functional so any hints are appreciated

    • @RawCoding
      @RawCoding  3 года назад

      Learn Clojure

  • @sunnypatel1045
    @sunnypatel1045 3 года назад +1

    Yes! Thank you mate

  • @stefanioan7569
    @stefanioan7569 3 года назад +4

    Did you bought your microphone second-hand? The sound is always very low.

    • @RawCoding
      @RawCoding  3 года назад

      Nope, I’m just shit at using it

    • @stefanioan7569
      @stefanioan7569 3 года назад +1

      @@RawCoding I'm sorry to hear that

    • @RawCoding
      @RawCoding  3 года назад +1

      Surprised you can hear it, my audio is shit

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

    I really liked that but painting 😁😋
    Talk more about that

    • @RawCoding
      @RawCoding  3 года назад

      My girlfriend drew it.
      I am only doing these programming tutorials to accumulate value on the butt painting and sell it for millions after many years, when I and the painting is famous!

    • @hadibazmi6340
      @hadibazmi6340 3 года назад

      @@RawCoding #respect
      I bid the first

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

    It won't work.
    Constructors do not return objects, but init fields of the current one. It is also impossible to reassign "this".
    In your case, there is just an output to the console, which does not mean that an object of the correct type has been created and returned.
    It was created and immediately destroyed.
    Without the lambda, the constructor code looks like this:
    public class DropDownMenu{
    public DropDownMenu(IFactory factory)
    {
    _ = factory.CreateButton();
    }
    }

    • @RawCoding
      @RawCoding  2 года назад

      No clue what you’re talking about

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

      @@RawCoding I mean that the created objects are not saved anywhere. Or is the initialization of the internal fields of the DropDownMenu omitted on purpose so as not to complicate the example? This makes it harder to understand the idea of ​​the pattern.

    • @RawCoding
      @RawCoding  2 года назад

      I’m explaining re usability of an object creation process. Showing how to then use the object is a waste of time.

  • @18Maxim18
    @18Maxim18 Год назад

    Nice description

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

    I see you like to torcher yourself with the painting on the wall. I’m referring to the very one on top.

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

    Thank you !

  • @Pixalynx
    @Pixalynx 3 года назад +1

    This is amazing !

  • @kapilpatel9379
    @kapilpatel9379 3 года назад

    Thanks for such good videos

    • @RawCoding
      @RawCoding  3 года назад

      Thank you for watching

  • @MrCommanderKid
    @MrCommanderKid 3 года назад +1

    Cool!

  • @oladipotimothy6007
    @oladipotimothy6007 3 года назад +1

    It's evident you enjoy the complexity involved lol

    • @RawCoding
      @RawCoding  3 года назад

      What complexity? This is simple no?

    • @oladipotimothy6007
      @oladipotimothy6007 3 года назад +1

      Implementation - simple
      Thinking - complex, but can be simple with time

    • @RawCoding
      @RawCoding  3 года назад

      Why is thinking complex?

    • @oladipotimothy6007
      @oladipotimothy6007 3 года назад +1

      Thinking is not complex. Proper application of thoughts can be complicated because there are different approaches to things.

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

    He makes a change and then moves the screen so that you don't get a chance to study the change, for example around 6:42. It's too fast to even pause there. Also, he doesn't show enough code in the same screen so I can't see how one thing affects the other. Quickly moving around, distracting hand gestures, imprecise definitions, etc.

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

    Maybe I'm just dumb

  • @pedroferreira9234
    @pedroferreira9234 3 года назад +1

    Hi bro, can you tell me the books you showed and/or books you recommend? Thx :) (Design pattern playlist lets gooo)

    • @RawCoding
      @RawCoding  3 года назад +1

      Holding:
      .NET Pro Memory Management
      Design Patterns (GoF)
      Structure and Interpretation of Computer Programs
      The Joy of Clojure
      Recommend:
      Clojure for the Brave and True (read it before The Joy of Clojure)
      Out of the Tar Pit github.com/papers-we-love/papers-we-love/blob/master/design/out-of-the-tar-pit.pdf
      Bob Martins (Uncle Bob) books really good for beginners

    • @pedroferreira9234
      @pedroferreira9234 3 года назад

      @@RawCoding amazing, gonna take a look! thx you

  • @piotrc966
    @piotrc966 3 года назад +1

    Seems Abstract Factory > Factory Method ;)

  • @wisnu7734
    @wisnu7734 3 года назад +1

    Why dont you use visual studio ?...i'm confuse what a Dump keyword for...

    • @RawCoding
      @RawCoding  3 года назад

      This is LinqPad, and dump prints object on to the screen. I dont like visual studio

    • @wisnu7734
      @wisnu7734 3 года назад +1

      @@RawCoding ohhh i see...i hope you'll switch to Visual studio some day..cause i have to think twice while you use linq pad...😄😄😄

    • @RawCoding
      @RawCoding  3 года назад +1

      Yeee that won’t be happening

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

      @@RawCoding might I suggest Jetbrains Rider?

    • @RawCoding
      @RawCoding  2 года назад

      What is that?

  • @iambonmucho
    @iambonmucho 3 года назад +1

    Is a deserializer not also a type of factory?

  • @moneymaker7307
    @moneymaker7307 3 года назад +1

    Can you make a video on event sourcing and how to store event in real word. This will complement your mediatr tutorial

    • @RawCoding
      @RawCoding  3 года назад

      Probably not, but I’ll see what I can do

  • @stefanioan7569
    @stefanioan7569 3 года назад +1

    Hi, any chance you can share the book list? Much appreciated 👍

    • @RawCoding
      @RawCoding  3 года назад

      I'll pin the comment

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

    Hi, do you have text version of video?

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

      Hi nope

    • @taraspelenio8259
      @taraspelenio8259 2 года назад

      @@RawCoding Ok, I'll read about it in some other place. Video is cool anyway)

  • @RoboChickenAnimation
    @RoboChickenAnimation 3 года назад +1

    Have u ever used the command pattern?

    • @RawCoding
      @RawCoding  3 года назад +1

      If I did not consciously

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

      @@RawCoding we use it where I work to interface with the domain level hardware functions. You plug generic commands into queues and lists and you can execute them in parrelell or in series and keep track on their errors and handle logging in a generic way. You could even use it to undo/redo events. It works well for our kind of stuff were we have multiple versions of the hardware sequences for different client applications. Also it makes fixing defects and changing behaviour really easily and it’s all plug and play.

    • @RawCoding
      @RawCoding  3 года назад +1

      Reminds me of some of things I’ve done, my approach is more functional where I just pass a function with some closures, which in turn becomes the command object.

    • @RoboChickenAnimation
      @RoboChickenAnimation 3 года назад +1

      @@RawCoding could do yeah. The class is more of a way to encapsulate a recovery command, a regular command, an undo and some error handling stuff. Sounds like a good approach tho especially if you’re just concerned about passing around the single function

    • @RawCoding
      @RawCoding  3 года назад +1

      I see, thanks for telling me, I’ll be reading more in to it when I’ll come to covering it