What is the Factory Pattern? | Software Design Principles

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2024
  • The factory pattern is one of the most popular design patterns. Factories help us delegate the responsibility of object creation to a dedicated object. Through polymorphism, we can further enhance this pattern. In this video, I define and discuss the utility of the Factory pattern and how it applies to software design. I also demonstrate the pattern through an easy to follow example.
    Become a Better Developer Using the Courses I Recommend Below:
    - Master FAANG Coding Interviews - bit.ly/3CVgRN9
    - Learn AWS From Scratch - bit.ly/3gasoAm
    - Master Python here - bit.ly/3yJFJpI
    Buy Head First Design Patterns Here: amzn.to/36r8aJT
    📚 MY RECOMMENDED READING LIST FOR SOFTWARE DEVELOPERS📚
    Clean Code - amzn.to/37T7xdP
    Clean Architecture - amzn.to/3sCEGCe
    Head First Design Patterns - amzn.to/37WXAMy
    Domain Driver Design - amzn.to/3aWSW2W
    Code Complete - amzn.to/3ksQDrB
    The Pragmatic Programmer - amzn.to/3uH4kaQ
    Algorithms - amzn.to/3syvyP5
    Working Effectively with Legacy Code - amzn.to/3kvMza7
    Refactoring - amzn.to/3r6FQ8U
    🎙 MY RECORDING EQUIPMENT 🎙
    Shure SM58 Microphone - amzn.to/3r5Hrf9
    Behringer UM2 Audio Interface - amzn.to/2MuEllM
    XLR Cable - amzn.to/3uGyZFx
    Acoustic Sound Absorbing Foam Panels - amzn.to/3ktIrY6
    Desk Microphone Mount - amzn.to/3qXMVIO
    Logitech C920s Webcam - amzn.to/303zGu9
    Fujilm XS10 Camera - amzn.to/3uGa30E
    Fujifilm XF 35mm F2 Lens - amzn.to/3rentPe
    Neewer 2 Piece Studio Lights - amzn.to/3uyoa8p
    💻 MY DESKTOP EQUIPMENT 💻
    Dell 34 inch Ultrawide Monitor - amzn.to/2NJwph6
    Autonomous ErgoChair 2 - bit.ly/2YzomEm
    Autonomous SmartDesk 2 Standing Desk - bit.ly/2YzomEm
    MX Master 3 Productivity Mouse - amzn.to/3aYwKVZ
    Das Keyboard Prime 13 MX Brown Mechanical- amzn.to/3uH6VBF
    Veikk A15 Drawing Tablet - amzn.to/3uBRWsN
    🌎 Find me here:
    Twitter - / beabetterdevv
    Instagram - / beabetterdevv
    Patreon - Donations help fund additional content - / beabetterdevv
    #FactoryPattern
    #DesignPatterns
    #SoftwareEngineer

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

  • @ThuyNguyen-bu9ge
    @ThuyNguyen-bu9ge 3 ปีที่แล้ว +32

    The factory pattern helps us to NOT repeat logic all over the place - there is one and only one place to create a new object. So if that new object some day needs new parameters or less parameters, then we don't need to change our code all over the place. We need to only update the Factory where the new object is created.

    • @IUfidi
      @IUfidi 2 ปีที่แล้ว +1

      nice.

  • @dovias5665
    @dovias5665 3 ปีที่แล้ว +12

    Why doesn't this have more views? That's premium content.

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +1

      Thank you so much for your kind words Dovias!

  • @2810quocviet
    @2810quocviet ปีที่แล้ว +1

    What a great video. After watching the video several times I've finally grasped the core concept.

  • @frederickjavalera558
    @frederickjavalera558 2 ปีที่แล้ว +5

    Great content! Did you ever get around to creating the second video on the abstract factory pattern that you mentioned at the end of this video?

  • @rezazaman1714
    @rezazaman1714 2 ปีที่แล้ว

    Excellent, it made my understanding clear on Factory Method. Waiting for your next video on Abstract Factory Pattern.

  • @frotes
    @frotes 3 ปีที่แล้ว

    Nice video. Would be interested in seeing the composition version you mentioned. I feel composition is the way to go for most things in OOP

  • @jedgraves8399
    @jedgraves8399 ปีที่แล้ว

    Super helpful. Thank you!

  • @hafsahmr9010
    @hafsahmr9010 3 ปีที่แล้ว +4

    The coding part really helps! Thank you so much! Would appreciate a video on Abstract Factory.

  • @nitinakash3275
    @nitinakash3275 3 ปีที่แล้ว

    Great contact.. Waiting for the second part

  • @AmrMekkawy
    @AmrMekkawy 2 ปีที่แล้ว

    Great clear explanation

  • @ganesh221b
    @ganesh221b 2 ปีที่แล้ว +1

    Thanks a lot Daniel, your videos are great!

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว +1

      Thanks Ganesh! Glad you enjoy them :)

  • @misoren9645
    @misoren9645 ปีที่แล้ว +2

    I still didn't get it. Isn't the main problem described as "violating the Open/Close Principle"?
    If we were to add a new kind of Pizza Type, we still would need to modify the if/else type block anyways, so how did creating all that new logic helped to solve the problem if it's still there anyways.
    Great content though.

  • @ThuyNguyen-bu9ge
    @ThuyNguyen-bu9ge 3 ปีที่แล้ว +1

    Very crisp, clear voice. Good teaching!
    Would you make a video about why we need the factory pattern - what problems the factory pattern is addressing?

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +1

      Hi Thuy, I see from your recent comment you figured out the value of this pattern! You hit the nail on the head :)

  • @ayingtorres5938
    @ayingtorres5938 3 ปีที่แล้ว +1

    This is an awesome channel!

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      Thanks Aying! Really appreciate the kind words.

  • @MrUnknowntraveller
    @MrUnknowntraveller 2 ปีที่แล้ว

    What blackboard tool are you using? Nice clear explanation. Thank you.

  • @ranjithaan5825
    @ranjithaan5825 2 ปีที่แล้ว +1

    did I miss the second part of Factory design pattern you have mentioned anywhere? could you please paste the link if you have posted on second part? thanks

  • @ihabhadjerci5238
    @ihabhadjerci5238 2 ปีที่แล้ว

    Great content thank you so much, I definitely subscribed,
    I have a question, what if we have added the ItalianStore Class and we give the user the right the store in the main class how would you know which Store will be choose and how would you handle it since we don't wanna to expose instantiation to client

  • @avanthasiriwardana
    @avanthasiriwardana 2 ปีที่แล้ว +1

    Good stuffs brother. Liked and Subscribed :)

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว +1

      Thank you and welcome to the channel!

  • @insightsacademy4214
    @insightsacademy4214 2 ปีที่แล้ว +1

    Very helpful

  • @Preotasherpa
    @Preotasherpa 3 ปีที่แล้ว +1

    Thank you so much.

  • @kshitizkumar2793
    @kshitizkumar2793 ปีที่แล้ว +1

    If the branching logic is still there in the second approach, doesn't it still violate the open close principle ?

  • @kais.alkotamy9798
    @kais.alkotamy9798 หลายเดือนก่อน

    quite an amazing course, I just want to say something that I wish it could be added which is how to approach using one of them "the use cases"

  • @IUfidi
    @IUfidi 2 ปีที่แล้ว +1

    Good. Liked. Subscribed.

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว

      Thank you and welcome to the channel!

  • @lorenzoferri7876
    @lorenzoferri7876 2 ปีที่แล้ว +3

    In the last part, when you describe the NYPizzaStore, you break the Open / Close principle anyway, right? wouldn't it be better and optimal to split It in two other classes (NYPepperoniPizzaStore and NYCheesePizzaStore)? I hope you clarify my question. Congratulations on the great video!

    • @alsonyang230
      @alsonyang230 ปีที่แล้ว +2

      Second this question. Wouldn't the NYPizzaStore still violates O/C principle if there is a NYStyleHamPizza added? Does having the factory abstract class do any better than the simple factory class?

  • @smirkedShoe
    @smirkedShoe 3 ปีที่แล้ว +3

    Great clarification 👏.
    Do we have a SOLID principles playlist ? I couldn't find it

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +2

      Hi Naman! Not yet but this is a great suggestion!

  • @parthshah438
    @parthshah438 2 ปีที่แล้ว

    could you please provide link for abstract factory deisgn pattern video as you have mentioned in video?

  • @aaa4363
    @aaa4363 ปีที่แล้ว +1

    Thanks!

  • @GEhehloopf
    @GEhehloopf ปีที่แล้ว

    Could you go over the Visitor Design Pattern?

  • @zemusic2736
    @zemusic2736 3 ปีที่แล้ว +2

    like your content, friend

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

    Shouldn't all these methods be outside of the Pizza class pizza.prepare(), pizza.bake(), pizza.cut(), pizza.box(), createPizza() and instead maybe be in the Factory?

  • @alex-dk2rj
    @alex-dk2rj 2 ปีที่แล้ว +1

    I'm confused because there is thousands of variations of toppings on new york pizza, so is this method practical for this example? Wouldn't you have thousands of classes?

  • @PoojaSharma-vt9xs
    @PoojaSharma-vt9xs 2 ปีที่แล้ว +1

    Really very clear explanation.

  • @mirzaaqeel
    @mirzaaqeel 3 ปีที่แล้ว

    Good material, can not see git hub link for the code you used in the example.

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      Hi Muhammad, check out this link for the code repository: github.com/beabetterdevv/DesignPatterns/tree/master/patterns
      I still have plans to create the remainder videos, stay tuned in the next few months.

  • @nehapandit1987
    @nehapandit1987 2 ปีที่แล้ว

    Is the Second part of this is ready?

  • @johnyonardpauly5601
    @johnyonardpauly5601 3 ปีที่แล้ว +1

    Dude, this looks like a paid udemy course. Thank you for this!

  • @saedyousef
    @saedyousef 2 ปีที่แล้ว

    This channel is so underrated ...

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว

      Thanks Saed, I'm glad you think so :)

  • @jakubrysiak3612
    @jakubrysiak3612 2 ปีที่แล้ว

    Why do you need the order method, since all it seems to do is call the create method?

  • @sagartyagi2450
    @sagartyagi2450 2 ปีที่แล้ว

    Isn't it simple Inheritance?? Why are we calling it a pattern?

  • @GustavoRubio
    @GustavoRubio 2 ปีที่แล้ว +2

    Midterm in 25 minutes boys. Time to set these videos to X2 speed