Factory Design Pattern - Why and How with Code!!

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 213

  • @premanshdewangan8695
    @premanshdewangan8695 3 роки тому +15

    Loved the way you explained the concept by taking an example and Step by step writing the code, talking about its disadvantages, and then coming to a solution by demonstrating the importance of Factory Method.
    Waiting for your upcoming videos.

    • @tusharjn
      @tusharjn 2 роки тому

      ua-cam.com/play/PLuO_Xyt86T60SIBUCHCEof_1ggJWH6QsQ.html

  • @RaunakShrivastava
    @RaunakShrivastava 3 роки тому +12

    There are plenty of resources for Design patterns in java and python on the internet but very few good resources for C++. This Design pattern series is like an oasis in desert for C++ developers. Thank you so much Keerti.

  • @abdulshahid7173
    @abdulshahid7173 2 роки тому +12

    I'm a c++ developer and was struggling to know the concept, believe me this is the best explanation I could find on UA-cam. Thanks for the video

  • @jatinsaini4787
    @jatinsaini4787 Рік тому +4

    At 4:25 we see that in our directory we have 6 files, bike.hpp/cpp; car.hpp/cpp; vehicle.hpp/cpp.But upon following the lecture from 1:35 till 4:25 we see that "vehicle.cpp" was never created, we only worked with "vehicle.hpp" throughout the mentioned time-range.What's inside "vehicle.cpp" ? then.Also At 5:10 while creating the library archive "vehicle_library.a", "vehicle.o" was not put into it just like "car.o" and "bike.o" were put. Was it intentional or a miss ? Same happened from 13:55 onwards while creating a library for "smart_client" i.e we didn't put "vehicle.o" into our library.Please shed some light on these points.

    • @nikhilmittal4378
      @nikhilmittal4378 11 місяців тому

      same doubt

    • @aneeshbose1323
      @aneeshbose1323 24 дні тому

      If the object files are not added to the library, just exclude them from the compilation. Since the correct header files are used in car and bike cpp files, it should not be a problem.

  • @mahtube735
    @mahtube735 3 роки тому +1

    I use this in most of my projects. I didn't know it was called factory method.
    Thank you for teaching.

  • @arjungupta250
    @arjungupta250 3 роки тому +24

    A great series to start really since there is so less quality content available on design patterns. Looking forward for next videos!
    One feedback, I feel many of the beginners must be struggling with the C++ commands to create excutable cpp files and archives or libraries. A brief explanation on those commands in the beginning of the next video or a separate video would really help.

    • @abhiroopsingh9320
      @abhiroopsingh9320 Рік тому +1

      Yes this is highly required as all the commands here are going above my head.

  • @akhilsharma1778
    @akhilsharma1778 3 роки тому +1

    Start of much needed series. My interviews are coming up so I don't know how much it will benefit me but this is a great start.

  • @Shourya_performs
    @Shourya_performs 2 роки тому +25

    You have to provide the pre requites to start this series.
    These things might not be known to everyone, considering myself to be an average student who has studied OOPs in C++.
    1. Code in header file. (How to write like #ifndef, etc).
    2. Less clarity of how many files already created and why?
    3. Everything was overwhelming. Should be slow and creation of files should be shown so that one can follow along.
    4. commands needs to be explained of the terminal.
    Idk about the rest but these are my honest opinions.

    • @amanasati5198
      @amanasati5198 7 місяців тому +3

      Go first learn and practice OOPs again. All the things were really basics of OOPs

    • @yogeshbaid6455
      @yogeshbaid6455 7 місяців тому

      I agree, I think C++ knowledge is pre-requisite here, it'd have been better if this was explained in Python

  • @swaathimeiyappan1819
    @swaathimeiyappan1819 2 роки тому

    Serious ly u have explained the concepts very clear.. till date I was using all this in my code without knowing why.. superb..

  • @Sachchin-7
    @Sachchin-7 Рік тому +2

    But isn't it still breaking the OpenClose Principle of Design Pattern. because we still need to make change in factory code whenever new vehicle is added!!!

  • @ajaymanagaon
    @ajaymanagaon Рік тому +2

    Used it in an Web Application where the application had to handle multiple database or different types. I needed to create the database object depending on the connection string passed.

  • @mdluffy-r6m
    @mdluffy-r6m Місяць тому

    Great explanation. Thanks a lot for doing this design pattern series !!

  • @harshitsingh4767
    @harshitsingh4767 3 роки тому +3

    I've used Factory design pattern once. I was wondering why we move the same if else logic into another class. Isn't it same.. But now it makes complete sense. We need to abstract the logic from the client code. Thanks !

    • @KeertiPurswani
      @KeertiPurswani  3 роки тому +2

      Yaaaaay!! Thank you! 😇😇
      Any constructive feedback? Rest of the tutorials should be like this only?

    • @harshitsingh4767
      @harshitsingh4767 3 роки тому

      @@KeertiPurswani Sure, I liked that it does not have any complicated code examples. The intention was just to understand what problem it overcomes and makes our life easier as a developer.
      And yeah, rest of the tutorials can be like this !

  • @tusharchaudhary3262
    @tusharchaudhary3262 3 місяці тому

    Hi Kriti ,
    I'm learning design patterns for the first time and I found some challenges in your video like you directly moved into the practical implementation and had not tell that for what purpose it is used for..... So I have to go somewhere else to understand that then I come back to your video. So please look into this issue.
    While the remaining explaination is really good.
    Thanks

  • @gouthamzz
    @gouthamzz Рік тому

    Thank you so much. I have been searching for many tutorials to know about design patterns in c++. I’m lucky that I came across this Vedio. Your explanation is simply superb

  • @roushanraj8530
    @roushanraj8530 2 роки тому +1

    Just waao Di, got it very easily, i have been reading the online vlogs and tutorials and always i was getting confused and not clear to me....., but this video made everything super easy ♥️💯
    One request, please complete this Playlist as soon as possible please 🙏 💜

    • @KeertiPurswani
      @KeertiPurswani  Рік тому

      I am sorry for being so late but I hope the quality pf explanation will make it upto you. Hoping you like the new videos! ❤️

  • @SauravKumar-vj7ks
    @SauravKumar-vj7ks 3 роки тому +8

    This was an amazing lecture. Superbly explained, all doubts cleared. Please ma'am explain all the possible design patterns. Really looking forward to this series. 👍

    • @KeertiPurswani
      @KeertiPurswani  3 роки тому +3

      Thank you so much Saurav, means a lot! Please do share the videos with your friends 😇😇

    • @SauravKumar-vj7ks
      @SauravKumar-vj7ks 3 роки тому +1

      @@KeertiPurswani Sure ma'am. Shared the video with all my friends and now you've got a bunch of folks ready to be taught design patterns using C++. Keep up the good work.👍😊

  • @subhashishsen6157
    @subhashishsen6157 2 роки тому

    What Can I say...Just the one which I wanted..Simple..Crisp..Clear.A Big Thumps UP

  • @Luckygangff
    @Luckygangff 7 місяців тому +1

    How to delete the object which dynamically created in im confused about deletion, we are having vehicle pointer and object created is different

  • @debajyotimajumder472
    @debajyotimajumder472 2 місяці тому

    I came to learn the factory design pattern and learnt how to create archive and object files too!! Wow

  • @cousinskitchentamil596
    @cousinskitchentamil596 2 роки тому

    Really well explained i have seen multiple videos couldn't grasp the concept but u nailed it thanks a lot please do more video like this

  • @shubhamtech89
    @shubhamtech89 3 роки тому +1

    With this if else you are polluting the Factory class as well. Imagine adding 10 more type of vehicles tomorrow. You have to maintain a registry of vehicle types added in a kind of hashmap. The key being the vehicle type, the value is the vehicle object.

  • @nageshpoojary271
    @nageshpoojary271 3 роки тому +4

    Nice explanation.. the way you explained the concepts of factory pattern is different than others (through library creation)..hoping for more videos..
    for remaining patterns advantages and drawback of using that pattern can also be discussed

  • @prathamsinghal5261
    @prathamsinghal5261 Рік тому

    I can tell you where Recently I have used this Pattern:
    I have designed three classes:
    1. GkeAgent
    2. EksAgent
    3. AksAgent
    Interface: IKubernetesService
    Implemeted Factory KubernetesServiceFactory.
    Based on the Properlty file value of the cloud type i am returning the suitable object.

  • @LaveshGarg
    @LaveshGarg 11 місяців тому

    short crisp and to the point explanation

  • @AnshulSharma-gq2vn
    @AnshulSharma-gq2vn Рік тому

    Kudos Keerti! This was really good!!

  • @cphash
    @cphash 3 роки тому +10

    I'm familiar with some design patterns like this, and hence, could follow everything properly. But thinking from a beginner's perspective, it could have been better :)
    Few observations:
    1. The explanation was tightly coupled to C++. A person learning design patterns shouldn't have to start with the library creation approach, that too involving C++ commands. Those are extra details that can be picked up later, if needed. I feel like you could have gone with a more generic and simpler approach, especially since this is the "Simple Factory Pattern".
    2. The video was kinda short. An in-depth explanation spanning half an hour would have been better. For instance, a comprehensive explanation could have been provided regarding the object creation approach, i.e., the reason behind doing Base B = new Child() instead of Child C = new Child() and its impacts since this acts as a prerequisite to understanding the factory approach.

    • @codegame6689
      @codegame6689 3 роки тому +2

      Very nice observation and feedback 👍

  • @rohitsingh-cn4fg
    @rohitsingh-cn4fg 3 роки тому +1

    I have one doubt of this kind of implementation of factory design pattern , I.e this code violate the open and closed principle of SOLID .
    Because whenever you will be adding new condition in the factory method you will be modifying , but principle says you code should be open for extension and closed for modification. So how could you handle please explain.

  • @palaktosh2256
    @palaktosh2256 2 роки тому +3

    @keerti can you please create videos explaining all design patterns as i don't find many design patterns easy to learn and adapt content. btw great job, you nailed the content on your channel. I am software engineer and currently pursuing masters from ASU and preparing for interviews for SDE2 roles.

    • @palaktosh2256
      @palaktosh2256 2 роки тому +2

      @keerti thank you for responding back and today I hold SD3 offer from Oracle and have started job previous week. Thank you for motivating and influencing Relevant content. Much love 😍

  • @hrishikesh328
    @hrishikesh328 2 роки тому

    Awesome explanation and one of the most simple explanation I have found on the Internet. Please include more videos

  • @snlagr
    @snlagr 3 роки тому

    This is very underrated, please make more videos in the series. I am sure it will garner more views in the long term! :D

  • @srikanthchivukula4555
    @srikanthchivukula4555 3 роки тому

    Nice explanation. Now i got cleared what factory pattern does.

  • @jagmohangautam1062
    @jagmohangautam1062 2 місяці тому

    In which of the scenarios would you use factory pattern and why?
    Consuming a service
    Complex Validation
    Logging
    Data Binding
    None of the Above

  • @aaaaz424
    @aaaaz424 Рік тому

    The bike and car are stored in a vehicle reference. What if there are functions which are not present in vehicle class but are present in bike or car class (not talking about overridden functions)?

  • @keerthi1070
    @keerthi1070 2 роки тому

    clarity at peaks :)

  • @mangeshjoshi5367
    @mangeshjoshi5367 6 місяців тому

    Hi Keerti, the client was still required to call createVehicle which i think could have been handled by the factory itself unless createVehicle is parameterised. Can you please explain why there is distinction between default constructor and createVehicle and what createVehicle is supposed to do?

  • @shankarBinnar-xl8en
    @shankarBinnar-xl8en Рік тому

    thanks..!! your way of presention is awsome...getting desigin patterns in new and detailed wayy!!😊

  • @sunitajoshi902
    @sunitajoshi902 2 роки тому

    I really love the way you explained....thanks for sharing play list.

  • @tech_wizard9315
    @tech_wizard9315 3 роки тому +2

    Please make a detailed video on how to make linkedin profile so strong that recruiters of tech giant's approach freshers (2020passouts) for job openings.

  • @rishabhkalra9505
    @rishabhkalra9505 3 роки тому

    i really like the way you explained. The example was not at all complex, simple vehicle objects work like charm. Would love to see a dedicated Design Pattern series which could help someone prep for OOD. Great Content.

  • @kesarshrivastava1221
    @kesarshrivastava1221 2 роки тому +2

    Hi Keerti! Thanks for creating the playlist. If you could show the code in Java too, it would be more helpful.

  • @abhimanyubhandari2454
    @abhimanyubhandari2454 2 роки тому +1

    Keerti saying "hi guys" is one of the few cutest things I experienced during a day🔥🔥

  • @DurgaShiva7574
    @DurgaShiva7574 3 роки тому +2

    thanks for this video. but.. whenever we make any changes in our factory class (say we add bus class), then we do need to recompile the whole factory class, as well as ask client to update the factory jar which they are using.. so is there any way to overcome this as well in this design pattern ??

    • @mrutunjaysingh4363
      @mrutunjaysingh4363 3 роки тому

      You can use dynamic library (dll/.so files), I think that should work.

  • @harshrajput3547
    @harshrajput3547 Рік тому

    What have you included in Vehicle.cpp 4:33?

  • @anmolsoni2704
    @anmolsoni2704 2 роки тому +2

    Hey Keerti, I just watched the video and I was able to get the concepts and advantages that you talked about in the video but I struggled with the implementation part cuz most of the things were completely new for me. So, could you please suggest any resources for learning the implementation of libraries and header files in c++?

  • @AyushMalik-t3z
    @AyushMalik-t3z 3 місяці тому

    Extremely well explained.

  • @tulikasnehil8733
    @tulikasnehil8733 3 роки тому

    Please make more of such videos explaining all design patterns with examples. This was very helpful

  • @kolakalapudinarasimhareddy5260
    @kolakalapudinarasimhareddy5260 2 роки тому

    Thanks mam until I worked on cpp 98 version.now I started giving interviews.i faced questions on design patterns I don't how they work,how I want use in project ur videos help lot to understand concept and practical
    Thank u mam a lot please do videos mam

  • @karishmasukhwani5270
    @karishmasukhwani5270 9 місяців тому

    Hi Keerti,
    Great explanation.
    I see some of createFactory classes include around 7-10 constructor arguments and pass the exact same or 1-2 more arguments to create the underlined class. It is little tightly coupled because does not give flexibility to accept new type of class in factory method, is this correct approach? To refactor, I think I can use ClassName as parameter in createFactory, and there will be additional 7-10 constructor arguments passed along.

  • @NDCraftCorner
    @NDCraftCorner Рік тому

    Hi keerti,
    I seen this factory design pattern video in that you create factory for separation of vehicle type. We can do that in stored procedure pass car, bike,truck, bus and get only those record and get faster execution can you give one more real time example

  • @varunguptapy7176
    @varunguptapy7176 8 місяців тому

    in first place you have not included vehicle oblect file vehicle.o in the vehicle liberary, you only added car & bike object file to library. Please explain

  • @himanshumathur9291
    @himanshumathur9291 Рік тому

    a very beginner friendly video. Nice explanation. One question - why we are not using the vehicle.o in creating the library ? Thanks in advance.

  • @archanashetty5250
    @archanashetty5250 2 роки тому

    Thank you so much, i was struggling to understand this honestly

  • @abhisheksaurabh2007
    @abhisheksaurabh2007 2 роки тому

    Simple and Nice Explanation , Waiting for New Lectures ,Thanku

  • @sunilthind3257
    @sunilthind3257 2 роки тому

    this is a wonderful video on factory design pattern. loved it

  • @shubhampokhriyal8491
    @shubhampokhriyal8491 3 роки тому +1

    How many total videos will be there in this series??

  • @whynesspower
    @whynesspower Рік тому

    Atleast 20 different concepts was discussed. Took me 2 hours to complete this tutorial

  • @4444-c4s
    @4444-c4s 6 місяців тому +1

    watched the video but still can't figure it out what's its real usage. I am in the field of web development

  • @rishabhgupta734
    @rishabhgupta734 11 місяців тому

    I believe in the last code example the vehicle objects are actually getting created in the factory method getVehicle method. The name of the funtion in bike and car classes should be changed from create vehicle to something else.

  • @santoshs4393
    @santoshs4393 Рік тому

    Thanks for the nice explaination. One query: In this pattern, whose responsibility is it to destroy the created vehicle object ?

  • @nikeshkumar-gl1fv
    @nikeshkumar-gl1fv 3 місяці тому

    Could you please create video on ROR and basically using RSpec for writing test cases please Mam

  • @balasubramanyam92
    @balasubramanyam92 2 роки тому

    Great Explanation ! Keep doing the videos.

  • @amitgupta-or5nm
    @amitgupta-or5nm 2 роки тому

    Awesome video keep making 🔥.

  • @chevvanthie3422
    @chevvanthie3422 3 роки тому

    Thanks keerti for sharing .. I'm eagerly waiting for all the videos in lld.

  • @poorvajas6600
    @poorvajas6600 2 роки тому +1

    Great explanation and a great series. Thanks for all the efforts. Why did you stop this series though :(

    • @KeertiPurswani
      @KeertiPurswani  Рік тому +1

      I know I am super late but never stopped, had a lot going on in personal life. Uploaded the new video today and hoping to finish the series super soon. Hope you like the video!

  • @ashokyamsani
    @ashokyamsani Рік тому

    Hi Keerthi, rather than going with the bookish / standard definition you have explained in in simple terms so that even novice programmer can understand. but I have a query here , you said that whenever there is a change in the requirement from the client we need to change the library and give it back to the client, I mean when client needs TEMPO vechile, we need to change the library and give it to him right ??

  • @rosansenapati-pl5hr
    @rosansenapati-pl5hr Рік тому

    For your upcoming video please zoom into your code so that we can get a clear view of it .... Lots of love ❤️❤️ love your teaching and love your contents

  • @swatiacharya9073
    @swatiacharya9073 Рік тому

    Nice explanation and thank you fir using c++

  • @varunguptapy7176
    @varunguptapy7176 8 місяців тому

    Please also made video for rest patterns mainly behavioral once like strategy pattern..

  • @santhoshreddy1284
    @santhoshreddy1284 2 роки тому

    thank you.. it helps us a lot. where can I find the code? did you upload in the git hub? can you please share the code paths?

  • @swapnilmishra697
    @swapnilmishra697 3 роки тому +1

    U really made whole concept soo easy..thanks alot.
    One request is it possible to make video on abstract factory.
    It seems bit difficult for me to understand conceptually.
    I understand when they give some example but still not able to understand when and where to use

    • @KeertiPurswani
      @KeertiPurswani  3 роки тому +1

      I will cover all the design patterns, please do share the videos with your friends as well 😇😇

    • @swapnilmishra697
      @swapnilmishra697 3 роки тому

      @@KeertiPurswani sure I will😊

  • @srilakshmiuvpakala3267
    @srilakshmiuvpakala3267 Рік тому

    Thank you very much for all your C++vedios. The videos are of great value. But, I still have question on factory design pattern.
    With the VehicleFactory class introduced , we are making smartclient independent as the code for any new vehicle needs to be implemented in VehicleFactory. However, dependent library for smart client is changing and that needs to be delivered to client everytime a change is made right........
    Where as without vehicleFactory client.exe should be rebuild by changing all the dependent libraries.
    My question is in anycase client gets a new deliverable right....

  • @mr.curious1329
    @mr.curious1329 3 роки тому

    Di you are doing a great job, pls make more videos .Greatly eager to learn 😊😊👍. Will share these videos too.!!

  • @mithunram4324
    @mithunram4324 3 роки тому

    Hey Keerti just saw this video today and your explanation is pretty neat and understandable. Waiting for other design patterns and lld content

  • @prasadmutnale773
    @prasadmutnale773 2 роки тому

    Excellent explanation keep growing...

  • @souvikbanerjee1396
    @souvikbanerjee1396 2 роки тому +1

    Awesome simplified explanation Keerti! 🙂Please continue the series covering major design patterns using c++ code examples. Please give a thought about making a video series on C++ multithreading as well. Many thanks! Keep up the good work. 🙂

  • @mohammedbiaskhan8092
    @mohammedbiaskhan8092 3 роки тому

    It was Really a good one to start with Design Patterns. Really Looking forward to this series.
    It would be even more good if you add descriptive things to remember at the middle or end to make a note of it for future reference and also adding interview perspective to this. Thanks Keerti.

  • @pratikshar1662
    @pratikshar1662 7 місяців тому

    Why haven't we used vehicle.o while compiling the library?

  • @kartikeyvishnoi2978
    @kartikeyvishnoi2978 3 роки тому

    Do continue this series! I really appreciate your effort 🙏🙏

  • @rein29233
    @rein29233 10 місяців тому

    Very easy to understand. Thank you.

  • @mapradnardev
    @mapradnardev 2 роки тому

    If in future there is a need to add new vehicle type then developer needs to change in existing library.Doesnt it violates the Open/closed principle?

  • @ravitejaag
    @ravitejaag Рік тому

    Very well explained 👍

  • @nooneknows3287
    @nooneknows3287 Рік тому

    I haven't found a link which point to code what we covered int this video, plz share code as well.

  • @tanmaythaker2905
    @tanmaythaker2905 Рік тому

    Thanks for this amazing video!

  • @kshitizkumar2793
    @kshitizkumar2793 Рік тому

    Nice explanation. But don't you think the if-else branching in your factory method will violate the Open Closed principle ?

  • @milindmore1977
    @milindmore1977 3 роки тому

    Really Nice Explanation !

  • @ichbinshiv
    @ichbinshiv 2 роки тому +1

    This is The Simple Factory pattern, not The Factory Design pattern. "The Simple Factory isn’t actually a Design Pattern; it’s more of a programming idiom." according to Head First Design Patterns. In addition, the use cases for the Simple Factory and Factory methods are not the same. The Factory method uses inheritance to provide a common framework; it does more than merely create objects.

  • @mehtalovish76
    @mehtalovish76 3 роки тому

    Really great content. I will just request you to release other lectures soon, so that the continuity doesn't breaks. Thank you for sharing your knowledge..

  • @sandeepsihoria5230
    @sandeepsihoria5230 2 роки тому

    good explanation mam😊

  • @arjundixit298
    @arjundixit298 3 роки тому

    Amazing stuff!

  • @MasumAhmed-fg8bc
    @MasumAhmed-fg8bc 3 роки тому +2

    Few points needs to make clear.
    1. Why that factory class is made static if not then what would happen?
    In real world scenrio is it done like this?
    2. More examples related to real work.
    The content length is good. Keep that but make it more advanced with focusing on low level design. 👍

    • @TakamiWoodshop
      @TakamiWoodshop 2 роки тому

      The factory class is _not_ static - that was clarified several times in the video. Only the getVehicle() method is static. If it was not, you would have to create an instance of the factory before you could use the getVehicle() method.

  • @suryamoymondal754
    @suryamoymondal754 Рік тому

    Nicely explained .

  • @amarjitnayak9725
    @amarjitnayak9725 Рік тому

    Can I have the code for all this patterns ? Explanation is super..

  • @vasukhungar2517
    @vasukhungar2517 2 роки тому

    Great explanation. Thankyou :)

  • @nitishkumar-m7r6p
    @nitishkumar-m7r6p 4 місяці тому

    Could you please help me understand what is there in vehicle.cpp file

  • @Adilakshmi_Nagiri
    @Adilakshmi_Nagiri 2 роки тому

    Hi Keerthi I think u have explained simple factory which is not a design pattern...can u explain factory method design pattern

  • @ss-md4qn
    @ss-md4qn 2 роки тому

    Amazing lecture .

  • @svarajdhanulkar1791
    @svarajdhanulkar1791 Рік тому

    But mam apko still jo first command hai gcc and all class name if age chal k truck ka class aya to usko bhi aapko gcc me lena hi padega so cpp me is that a problem or not I am not sure but
    This design pattern definitely solves problem of object creations for above use case

  • @Pupperoni938
    @Pupperoni938 Рік тому

    Good explanation, thanks.

  • @sahilnaik7681
    @sahilnaik7681 6 місяців тому

    But doesn't it breaks the concept of Open Closed Principle because we are still modifying our VehicleFactory class. Please clear