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

Sdílet
Vložit
  • čas přidán 25. 07. 2024
  • Explanation & Examples for the Factory, Abstract Factory and Factory Method design patterns.
    Patreon 🤝 / raw_coding
    Courses 📚 learning.raw-coding.dev
    Shop 🛒 shop.raw-coding.dev
    Discord 💬 / discord
    Twitter 📣 / anton_t0shik
    Twitch 🎥 / raw_coding
    👉 Try Rider
    www.jetbrains.com/store/redeem/
    RD5K9-4TXXW-KMV3G-NYWSF-3ZSTP
    Playlist: • c# design patterns
    Source: github.com/raw-coding-youtube...
    #csharp #designpattern #factory

Komentáře • 94

  • @sebad_informatica5696
    @sebad_informatica5696 Před 3 lety +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  Před 3 lety +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 Před 2 lety +7

      try no to stick to bla-bla terminology.

    • @rapoliit
      @rapoliit Před 7 měsíci

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

  • @cihangirbozdogan4549
    @cihangirbozdogan4549 Před rokem +5

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

    • @RawCoding
      @RawCoding  Před rokem +1

      Cheers! Make sure to check out the playlist

  • @maneeshpardeshi4032
    @maneeshpardeshi4032 Před 2 lety +3

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

  • @AlexxXRecorD
    @AlexxXRecorD Před 2 lety +4

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

  • @liangbinyu7620
    @liangbinyu7620 Před rokem +1

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

  • @mahmoudalaskalany
    @mahmoudalaskalany Před 3 lety +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

  • @adwers-comdamiannass4561

    Beautiful explanation, just Beautiful❤. Thank You👏

  • @saurabhchauhan232
    @saurabhchauhan232 Před 3 lety +3

    Thank you ! Finally Design pattern started,

  • @kapilgupta4409
    @kapilgupta4409 Před 3 lety +4

    Amazing ! You are an outstanding developer.

  • @amirh.jabari5401
    @amirh.jabari5401 Před 3 lety +6

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

  • @rozezard862
    @rozezard862 Před 10 měsíci +1

    Liked your background, not distracting at all ;-)

  • @sunnypatel1045
    @sunnypatel1045 Před 3 lety +1

    Yes! Thank you mate

  • @nokostunes
    @nokostunes Před 2 lety +2

    thank you for the simple explanation :]

  • @pereirao
    @pereirao Před 3 lety +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! ^_-

  • @RawCoding
    @RawCoding  Před 3 lety +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

  • @cicerofoscarini8890
    @cicerofoscarini8890 Před 2 lety +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  Před 2 lety

      Cheers my dud all is good, I still upload videos

  • @Pixalynx
    @Pixalynx Před 3 lety +1

    This is amazing !

  • @Furki4_4
    @Furki4_4 Před rokem

    Thank you !

  • @kapilpatel9379
    @kapilpatel9379 Před 3 lety

    Thanks for such good videos

  • @18Maxim18
    @18Maxim18 Před rokem

    Nice description

  • @domantasg7660
    @domantasg7660 Před 3 lety +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  Před 3 lety

      Don’t really do DDD

    • @hadibazmi6340
      @hadibazmi6340 Před 3 lety +1

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

    • @RawCoding
      @RawCoding  Před 3 lety +1

      Yes, I prefer functions )

    • @hadibazmi6340
      @hadibazmi6340 Před 3 lety

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

    • @RawCoding
      @RawCoding  Před 3 lety

      Learn Clojure

  • @MrCommanderKid
    @MrCommanderKid Před 3 lety +1

    Cool!

  • @pedroferreira9234
    @pedroferreira9234 Před 3 lety +1

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

    • @RawCoding
      @RawCoding  Před 3 lety +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 Před 3 lety

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

  • @stefanioan7569
    @stefanioan7569 Před 3 lety +1

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

  • @stefanioan7569
    @stefanioan7569 Před 3 lety +4

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

    • @RawCoding
      @RawCoding  Před 3 lety

      Nope, I’m just shit at using it

    • @stefanioan7569
      @stefanioan7569 Před 3 lety +1

      @@RawCoding I'm sorry to hear that

    • @RawCoding
      @RawCoding  Před 3 lety +1

      Surprised you can hear it, my audio is shit

  • @moneymaker7307
    @moneymaker7307 Před 3 lety +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  Před 3 lety

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

  • @iambonmucho
    @iambonmucho Před 3 lety +1

    Is a deserializer not also a type of factory?

  • @hadibazmi6340
    @hadibazmi6340 Před 3 lety +2

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

    • @RawCoding
      @RawCoding  Před 3 lety

      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 Před 3 lety

      @@RawCoding #respect
      I bid the first

  • @taraspelenio8259
    @taraspelenio8259 Před 2 lety +1

    Hi, do you have text version of video?

    • @RawCoding
      @RawCoding  Před 2 lety +1

      Hi nope

    • @taraspelenio8259
      @taraspelenio8259 Před 2 lety

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

  • @TheAlien1900
    @TheAlien1900 Před 2 lety +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  Před 2 lety

      No clue what you’re talking about

    • @TheAlien1900
      @TheAlien1900 Před 2 lety +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  Před 2 lety

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

  • @stefanioan7569
    @stefanioan7569 Před 3 lety +2

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

  • @benjeee4299
    @benjeee4299 Před 11 měsíci +3

    Maybe I'm just dumb

  • @wisnu7734
    @wisnu7734 Před 3 lety +1

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

    • @RawCoding
      @RawCoding  Před 3 lety

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

    • @wisnu7734
      @wisnu7734 Před 3 lety +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  Před 3 lety +1

      Yeee that won’t be happening

    • @DarthYoda2513
      @DarthYoda2513 Před 2 lety +1

      @@RawCoding might I suggest Jetbrains Rider?

    • @RawCoding
      @RawCoding  Před 2 lety

      What is that?

  • @oladipotimothy6007
    @oladipotimothy6007 Před 3 lety +1

    It's evident you enjoy the complexity involved lol

    • @RawCoding
      @RawCoding  Před 3 lety

      What complexity? This is simple no?

    • @oladipotimothy6007
      @oladipotimothy6007 Před 3 lety +1

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

    • @RawCoding
      @RawCoding  Před 3 lety

      Why is thinking complex?

    • @oladipotimothy6007
      @oladipotimothy6007 Před 3 lety +1

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

  • @user-nw8oi9vn9y
    @user-nw8oi9vn9y Před rokem +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.

  • @piotrc966
    @piotrc966 Před 3 lety +1

    Seems Abstract Factory > Factory Method ;)

  • @RoboChickenAnimation
    @RoboChickenAnimation Před 3 lety +1

    Have u ever used the command pattern?

    • @RawCoding
      @RawCoding  Před 3 lety +1

      If I did not consciously

    • @RoboChickenAnimation
      @RoboChickenAnimation Před 3 lety +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  Před 3 lety +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 Před 3 lety +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  Před 3 lety +1

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