No video

Factory Method Design Pattern in Java, tutorial

  Рет қаралды 80,519

Ranjith ramachandran

Ranjith ramachandran

9 жыл бұрын

Here I explain the factory method design pattern defined in GoF's famous design pattern book. There is a practical example that I hope will make the concept clear. If you have any comments, let me know.
#macbookair #java #javainstitute #javaprogramming #javatutorial #javascript #easy #designpatternsinjava #design #beginners #beginner #easylearning #study #learnjava

Пікірлер: 118
@rahulshinde6070
@rahulshinde6070 5 жыл бұрын
Fantastic! Real world example of factory method pattern.There are many vedios showing simple factory as factory method.Thank you.
@saikrishna-mn7nd
@saikrishna-mn7nd 2 жыл бұрын
Great Video, Great explanation..
@aliim1
@aliim1 3 жыл бұрын
Hey Ranjith. Not sure whether your active here or not. Just putting out a note to say Thank you. Ur explanation was crisp and clear. Infact I landed a job in Amazon after that. It was like more than 2 years ago. I didn't had your contact until recently I saw ur channel. Thanks a lot :) it's pity that u have not uploaded anything new
@Apprenticer
@Apprenticer 2 жыл бұрын
6 years later. Your work is still valuable .
@vijayv05
@vijayv05 8 жыл бұрын
Ranjith, A big time Thanks to you. By watching your videos I cracked an interview. Whole credit goes to your videos.
@akshaychandra5480
@akshaychandra5480 8 жыл бұрын
Love all your videos. I have watched tutorials on KZfaq, Coursera, Udemy and lot of other such websites and your videos are the best. I watched your video on HashMaps, Hashtables, Singleton, Factory, Garbage Collection and each one of them have made the concepts really clear. I am a grad student and I must admit, I have learnt more from watching your videos than studying Computer Science for the past 6 years. Please post more videos. Thanks
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Akshay Chandra Thanks for the kind words. yes, a lot of effort goes in to making these videos and that's why I haven't released anything new for a few months.
@ranjithramachandran5928
@ranjithramachandran5928 7 жыл бұрын
Steve Hans pls message me on channel
@aidenavi5976
@aidenavi5976 3 жыл бұрын
A tip : watch series at kaldrostream. Been using them for watching a lot of movies recently.
@wellsjaxton5570
@wellsjaxton5570 3 жыл бұрын
@Aiden Avi yup, I have been using kaldroStream for since november myself =)
@pandit-jee-bihar
@pandit-jee-bihar 4 жыл бұрын
This is by far the most clear and detailed explanation of factory pattern.
@abhipawar333
@abhipawar333 6 жыл бұрын
Very nice
@VasileSurdu
@VasileSurdu 3 жыл бұрын
thanks for your explanation
@kotireddysareddy8087
@kotireddysareddy8087 6 жыл бұрын
Very good tutorial
@SushilYadav7
@SushilYadav7 2 жыл бұрын
Great explanation. 👏🏻 Please make a video on abstract factory.
@amitjoc
@amitjoc 6 жыл бұрын
Bravo NICE and Simple Explanation
@balajifullstack5800
@balajifullstack5800 5 жыл бұрын
loaded with awesomeness, this is a clear and great explanation about factory method model. thanks, bro.
@SabaS2105
@SabaS2105 8 жыл бұрын
Crisp and nice explanation. Looking forward to more videos on Design patterns. Thanks!
@pandit-jee-bihar
@pandit-jee-bihar 4 жыл бұрын
Please create more such tutorials. It's really helpful and saves a lot of time and effort during revision.
@vinayakvaravate9261
@vinayakvaravate9261 7 жыл бұрын
awesome explanation! I am following your videos. Please keep posting the videos.
@NafisaAtiyaKhan
@NafisaAtiyaKhan 7 жыл бұрын
Excellent Tutorial. Very clear to understand. Thank You.
@alexanderkarpenko2407
@alexanderkarpenko2407 8 жыл бұрын
Very helpful. clear explanation.
@vishalsrane
@vishalsrane 5 жыл бұрын
Awesome. You are giving practical scenarios, thats an huge help fo me. thank you sir.
@ManishKumar-sv5my
@ManishKumar-sv5my 4 жыл бұрын
Thanks man, great tutorial
@katdareshruti
@katdareshruti 3 жыл бұрын
Please make more design pattern videos!
@priyakdey7891
@priyakdey7891 4 жыл бұрын
@Ranjith ramachandran you have amazing content with not only scrapes the surfaces but takes a topic and goes in dept. These are not just starter videos, these are well-designed videos to get a deep dive. Just one question - Why silent for 4 years !!!! You have 30k subs and nearly 2 mil views with jsut 10 videos. You have amazing content and would be glad to see you back ! :)
@ckm5101
@ckm5101 7 жыл бұрын
Learning a lot from your videos thank you so much , hope post more videos regarding different topics ....
@shogv48
@shogv48 6 жыл бұрын
All your videos are very informative and very well explained. Looking for more videos on design patterns
@PickledDragon
@PickledDragon 7 жыл бұрын
Your videos are well organised and resourceful unlike many others camouflaged as Java tutorials. A job well done. You should create more videos.
@srikanthkolipaka2103
@srikanthkolipaka2103 8 жыл бұрын
Very nice explanation Ranjith , lot helps me to understood about Factory method DP
@Knightsthatsaynih
@Knightsthatsaynih 7 жыл бұрын
You deserve more than 8k subscribers. One of the best content for java online.
@vivek2032
@vivek2032 9 жыл бұрын
Hi Renjith. The video was really informative. I would really appreciate if you post a video on Multi threading
@iminsane7777
@iminsane7777 7 жыл бұрын
These videos are so crystal clear. Even someone from non computer science background can understand them. Thanks Ranjith I really love these videos.. ! Waiting for your next.. :)
@jtnkathuria
@jtnkathuria 8 жыл бұрын
Man... you are just awesome and highly inspiring. Great work.. Keep it up!
@SrinathRayabarapu
@SrinathRayabarapu 9 жыл бұрын
Hi Ranjith, thanks for yet another video on Design patterns. This video made me to understand Factory pattern more clear. One request what i have is, Can you please share the end source code that you have come up while explaining the concept? This will act as local reference to me whenever i want to have a quick look to recall the concept. Thanks a lot. Looking forward for more interesting topics from you! Cheers, Srinath.
@gunasekhar2729
@gunasekhar2729 7 жыл бұрын
awesome buddy...... we are expecting more vidoes from you......😇😇😇😇😇 really very very informative....
@ashrafs965
@ashrafs965 6 жыл бұрын
You are really good at explaining. we are missing your tutorials!
@sheraz_razzaq
@sheraz_razzaq 4 жыл бұрын
Thank you Dear, your lecture was awesome... try to make new videos. because your way of teaching is very awesome. Thank you again.
@syedhafeezdaimi6526
@syedhafeezdaimi6526 8 жыл бұрын
Ranjith, appreciate your work. You have very good style of teaching. thanks
@razoryonov
@razoryonov 8 жыл бұрын
great video
@vipinjainoo7
@vipinjainoo7 8 жыл бұрын
Hi Renjith. The video was really informative. I would really appreciate if you post all other Design Pattern
@vincentantonyraj
@vincentantonyraj 8 жыл бұрын
Fantastic explanation! Keep rocking Rajith!
@aman.sharma2792
@aman.sharma2792 7 жыл бұрын
Hi, Thanks for sharing in such a classy way. Would want you to cover some other topics such as Collections and Exception handling.
@KrishnaPrasad-qt7ke
@KrishnaPrasad-qt7ke 6 жыл бұрын
Really nice explanation. Thanks a ton Ranjith.
@raviranger52
@raviranger52 8 жыл бұрын
Hi Ranjith , this is Super .. thanks !!! just a suggestion , just like you had the presentation already prepared , if you can have the sample code also pre-written before doing the video , i think that will be great , that way you would have communicated all the information in about say 15 mins... it will be more crisp that way... nobody wants the sample code to go away but if it's pre written the video becomes shorter :)
@chandrashekar4728
@chandrashekar4728 4 жыл бұрын
Please do more videos on streams....
@siddhilalabobo3597
@siddhilalabobo3597 5 жыл бұрын
Hello sir, why you have stopped making this kind of great videos. looking forward to more java videos, which can help many of us
@sushilsajane4392
@sushilsajane4392 7 жыл бұрын
hey u r really doing awesome job....need some more vdos
@krishnamohan5271
@krishnamohan5271 3 жыл бұрын
Bro, You should create more such videos, quite liked it.
@AbhimitaDebnath
@AbhimitaDebnath 8 жыл бұрын
great tutorials. all of the topics covered are excellent. if you could provide the codes for the examples, it will be an added advantage. keep posting Ranjith.
@ishantbhatia3194
@ishantbhatia3194 6 жыл бұрын
pls make many more videos , u r awsm
@risabhkumar7149
@risabhkumar7149 7 жыл бұрын
Please provide links for other Design patterns . That would be a great help . Really Excellent.
@anmoldevgan7960
@anmoldevgan7960 8 жыл бұрын
hello ranjith I'm BY too much impressed when i watched video of jvm how really works it too much clear and explained very GOOD plZ plz plz give me video on CONCURRENY chapter i shall very thank full TO have nice time.... and ur brilliant
@mayursahdev
@mayursahdev 6 жыл бұрын
Hi Ranjith , I loved your videos , these are very informative. Its been long , please post more videos
@neerajmahajan1305
@neerajmahajan1305 6 жыл бұрын
This one is awesome!
@isamarsharma
@isamarsharma 8 жыл бұрын
waiting for other videos on design pattern
@jating4you
@jating4you 3 жыл бұрын
You are doing a great job, sir!! why you stopped making java videos..?
@KD-sv5cz
@KD-sv5cz 3 жыл бұрын
Have you created any other KZfaq channel. Why are you not uploading any more videos?
@navjhs
@navjhs 4 жыл бұрын
Ranjit Sir, please upload more videos. Or if you are having udemy tutorials then please share the link. You are simply awsome.
@shobhak3320
@shobhak3320 8 жыл бұрын
awesome explanation .... can u plz upload some videos on real projects in java, it will help lot of freshers to build their confidence...
@andrewdudley3408
@andrewdudley3408 3 жыл бұрын
A bit confused here. Every video on Factories start out by saying how it allows you to avoid creating switch/if-thens multiple times throughout your code, when you don't know until runtime what object instance type you need. Makes sense. So then they move the switch logic into a factory. Then, they say "well, now we're violating the open-close principle. So we'll create an abstract factory and delegate the creation of the objects to concrete factory instances for that object type. Makes sense, now you just have to create a concrete factory for each type, they'll implement the abstract factory. All good UNTIL you realize that you once again have to create a switch statement somewhere that maps from your typeString ("text", "csv", "xml") to the corresponding abstract factory. You can do this in a factory method (as shown here), but then you're once again violating the open-close principal, because you now have to update the switch statement everytime you have a new type.
@deeptimonga7375
@deeptimonga7375 3 жыл бұрын
Yes even I have the same doubt! Please answer
@ranjithramachandran5928
@ranjithramachandran5928 3 жыл бұрын
Another way to look at OCP is that a 'class should have only one reason to change' - so we will not modify the BatchProcessor when a new parsing requirement has come. Its concerns is only the processing algorithm. It is not concerned about parsing. It is open for extension by providing a factory method. Coming to the if-else - it will belong where selecting the right processor will be the concern. And certain techniques like using a map or reflection can be employed if you really want to make the if-else 'go away'.
@andrewdudley3408
@andrewdudley3408 3 жыл бұрын
​@@ranjithramachandran5928 Thanks for the reply, Ranjith. My current simple factory method employs the use of a map with a .register() function. Of course, this means at some point the user must register their {key: class} combinations. Any suggestions on where these register calls should be placed? Also, I'm in a position where, for each type, I need to be able to build multiple corresponding UI elements. For example, each type corresponds to a "cell" component, as well as a "sidebar" component. Does this mean I should be registering two different concrete factory classes for each type (key), or should I be registering one concrete factory per key, and have the factory be responsible for creating any corresponding UI elements/components.
@ranjithramachandran5928
@ranjithramachandran5928 3 жыл бұрын
@@andrewdudley3408 Your scenario sounds like you need to create a "family of related objects" - Take a look at Abstract Factory - that pattern helps to solve this situation better.
@ruchikakapoor9016
@ruchikakapoor9016 6 жыл бұрын
Why have you stopped uploading your videos. They were all so good. Wish you could continue your channel.
@ShabYouify
@ShabYouify 7 жыл бұрын
Hi Ranjith, Great tutorials... very precise with examples.. can't find more links on other design patterns, can you please help me find. Thanks a ton buddy!
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
in this mechanism if you want to delete the TextParser it is not possible................we are extending test parser with csv parser ...............rather than we can implement the paser interface is better way?
@NileshKamani
@NileshKamani 8 жыл бұрын
I see that you haven't uploaded any new videos. I hope you are doing well. Great videos.
@seep3963
@seep3963 5 жыл бұрын
Hi Ranjith, Why did you stoped uploading videos? You were doing an amazing job. Still hoping for further videos on Java 8,9,10,11 updates.
@rebeccaswarna7369
@rebeccaswarna7369 7 жыл бұрын
great explanation... but then again, if i want to support some other file format (docx) again i have to modify the App.jave ,So is there a way to get the class name in App.java with out hard coded value
@ashrafs965
@ashrafs965 7 жыл бұрын
Thanks so much. hope you create more videos or even complete paid courses on Udemy or whatever platform.
@pranayraherkar6935
@pranayraherkar6935 7 жыл бұрын
Hello Ranjit, the video was good and it's really helped me but still I am confused, Can you explain using with example, what is difference between static factory method and singleton design pattern. means when to use static factory and when to use singleton .
@kanchantiwari5175
@kanchantiwari5175 9 жыл бұрын
It is really helpful for the beginners . Can you please share some portion of multithreading too.
@ranjithramachandran5928
@ranjithramachandran5928 9 жыл бұрын
+kanchan tiwari Sure- its in the plan. please subscribe; I generally update 1 video in 2 weeks.
@kanchantiwari5175
@kanchantiwari5175 9 жыл бұрын
+Ranjith ramachandran Thanks . Already subscribed , I am following your videos from Hashmap internal implementation that was very helpful to make my doubts clear....
@azeezpaloor1202
@azeezpaloor1202 5 жыл бұрын
Thanks Ranjith for this wonderful tutorial. Is there any difference between factory design pattern and factory method design pattern?
@narendratechguy7140
@narendratechguy7140 8 жыл бұрын
Please upload vids on Java multi threading Thanks in advanced
@sathishkumarbt
@sathishkumarbt 8 жыл бұрын
you mentioned about Dependency inversion principle being violated.How did you conclude that BatchProcessor is a higher module?.. i am bit confused on this aspect
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Sathish Kumar have a look at diagram at 26:01 mark. The class encapsulates complex logic(so to speak) and do not have low level details about files it can handle etc.
@ashvajitchauhan608
@ashvajitchauhan608 6 жыл бұрын
please upload video on multithreading
@fazilmes
@fazilmes 4 жыл бұрын
No new videos for long. Do you have any other source of videos?
@vivek2032
@vivek2032 8 жыл бұрын
Dear Ranjith, Hope you are doing well. From many days you have not posted any videos .. I hope we will see new video of some concepts explained pretty soon.
@PawanKumar-ni4um
@PawanKumar-ni4um 7 жыл бұрын
hello rajnith i have a doubt , why All wrapper class is immutable what is the reason of behind ? please reply.
@simensanjeetha8405
@simensanjeetha8405 8 жыл бұрын
Sir, I understood the factory design pattern very clearly from your tutorial and even the example that you have used. But I have a doubt. In most textbooks and videos while explaining the factory design pattern they give an example with one factory class which contains the factory method. But in your tutorial you have an abstract class and two concrete sub classes and I understood and agree with the explanation you gave for it. My doubt is that: Suppose there is only one factory class that contains a method that returns an object based on the parameter passed to it,.. Is this method just a static/simple factory method? and Does this class implement the Factory Design Pattern as defined by the GOF?
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Simen Sanjeetha - For purists . that's just a simple factory. It does not adhere to GOF's definition of factory method design pattern. So IMHO it is not factory method design pattern. But I see that most of the developers consider a static method that returns an Object as "Factory method design pattern" these days;
@simensanjeetha8405
@simensanjeetha8405 8 жыл бұрын
+Ranjith ramachandran Oh ok, Thank you Sir, your tutorial and example is very unique and the most sensible of all that i have come across. Also, I really enjoyed the Single pattern tutorials as well. Great material for beginners. I request you to post tutorials on abstract factory design pattern and DAO design pattern as soon as you can. Hope to learn more from you. Thanks again.
@MS-ib4tp
@MS-ib4tp 8 жыл бұрын
Thank you!
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
hai sir.............whun u upload thread concurenyy................plz reply me i am waiting for that?
@samirpanda97
@samirpanda97 8 жыл бұрын
the way yu xpln is damn good bt u upload nly limited vdo ..so request u to upload some more topic
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+samir panda , I try.. I have a day job and its hard to find time. But the goal is to add a new video every 2 weeks.
@abc20819
@abc20819 8 жыл бұрын
It is really helpful video for beginners though the example you are using, in my view, is actually violating behavioral design pattern. Rather than different batch processors, we should have one ParserUtil which would have given a parser based on the arg we pass. This way we could have saved creating many BatchProcessor and could have used Composition Over Inheritance. Please let me know your views.
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Abhinav Gupta , Thanks for the the feedback. I tried to keep the example very basic. Is that a very good design? Debatable! That apart, please note that patterns like these are used in OO based libraries and frameworks. Given that if you provide a ParserUtil in your framework, that framework is not extensible; rather it is violating OCP(open closed principle) and every time we add a new format, we need to edit ParserUtil and we might be introducing bugs. Yes, we should favor composition over inheritance. Composition has its own use-cases and sometimes we end up introducing coupling(there are patterns that addresses that). In certain cases it is preferable, in some cases we go back to good old OO inheritance(note we have abstract class and template method in that example).Principles and patterns are like salt in food, it should be to the right amount and also depends on the dish :-)
@abc20819
@abc20819 8 жыл бұрын
As you correctly said, we need to add salt as per the taste and also as per the dish but what matters most is what kind of salt it is. Anyways I like the way you presented this topic and also like your lecture on JVM architecture. Thanks again.
@ManishKumar-sv5my
@ManishKumar-sv5my 4 жыл бұрын
How to implement Abstract Factory Design Pattern ?
@harishsure9562
@harishsure9562 6 жыл бұрын
sir please upload video regards rxjava
@TheDibyendusarkar
@TheDibyendusarkar 6 жыл бұрын
Can some one please tell me. Is there anything called Abstract Factory Pattern
@bhaskarsuthar7600
@bhaskarsuthar7600 8 жыл бұрын
Hi Ranjith, Thanks for posting this video with awesome explanation. Can you post some lectures on Executor framework as well ? Thanks :)
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Bhaskar suthar yes, it is WIP.. hard to edit the content to fit in to a 30 min yt video..pls bear with me and subscribe.. so that you will get notified when I upload it.
@bhaskarsuthar7600
@bhaskarsuthar7600 8 жыл бұрын
+Ranjith ramachandran already did sir.. You can split video lectures in short sessions as well, just in case 😊.. By the way thanks a lot for sharing all awesome lectures...
@gnanrajv
@gnanrajv 6 жыл бұрын
Ranjith ramachandran Ranjith you videos are awesome, just curious why no new releases from you..
@madhusudhandumpa9464
@madhusudhandumpa9464 6 жыл бұрын
Can you please provide abstract factory pattern
@fabulousvab
@fabulousvab 8 жыл бұрын
Hi, in this approach if I have 100 formats I would be required to make 100 classes to return the object .. what if need to do that from only 1 class .. can Reflection be used to implement that
@anumonto
@anumonto 8 жыл бұрын
Yes, using reflection will remove the else-if ladder from client .. this will require some changes in BatchProcessor. That will be more clean approach. Nice example is given under 'Polymorphic factories' in Bruce Eckel's 'Thinking in Patterns' book..
@srinish1993
@srinish1993 7 жыл бұрын
Bruce Eckel books are the best(Y)
@bharatdodeja
@bharatdodeja 8 жыл бұрын
Can you extend the same example for Abstract Factory design pattern and upload new tutorial?
@ranjithramachandran5928
@ranjithramachandran5928 8 жыл бұрын
+Bharat Dodeja Sure, it is in works. Note that abstract factory is to build a family of related products.
@bharatdodeja
@bharatdodeja 8 жыл бұрын
I have rough idea about Abstract Factory pattern, just want to see how can we apply it over here and get rid of if else conditions.
@ytpolice1523
@ytpolice1523 5 жыл бұрын
why did you stop making videos?
@mosup5007
@mosup5007 4 жыл бұрын
I don't know but It looks for me like the Template Method design pattern more than Factory Method
@harishchowdarysure8858
@harishchowdarysure8858 8 жыл бұрын
sir when u upload thread concurrency.....................reply me
@gurdeepkaur7490
@gurdeepkaur7490 7 жыл бұрын
Try to use easy example
@amirsmair71
@amirsmair71 6 жыл бұрын
totally right (Y)
@prashanthambure3235
@prashanthambure3235 2 жыл бұрын
Isn't this abstract factory design pattern and not factory method design pattern? Just trying to understand, no offence.
@ranjithramachandran5928
@ranjithramachandran5928 2 жыл бұрын
No = the abstract factory design pattern is to create a "family" of objects. A classic example would be the GUI controls such as button, label, input etc for windows vs mac vs linux vs motif etc - that's the kind of scenario that abstract factory solves.
@aditigoyal2622
@aditigoyal2622 9 жыл бұрын
hi sorry but it is not too good...well it is average. what about another GC video?
@ranjithramachandran5928
@ranjithramachandran5928 9 жыл бұрын
+aditi goyal Thanks for the feedback. Please let me know what aspect of it has to be improved. For GC, are there any specific areas you were looking for?
@aditigoyal2622
@aditigoyal2622 9 жыл бұрын
+Ranjith ramachandran Hi , actually i don't know exactly but as comapred to your others videos it is not effective to that level...About GC , you said that 1st video was basic and you are planning to post another video and my focus is on performance tuning :)
5 Design Patterns Every Engineer Should Know
11:51
Traversy Media
Рет қаралды 936 М.
About java.lang.String, why String is special in java - String tutorial
39:19
Ranjith ramachandran
Рет қаралды 109 М.
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 33 МЛН
Harley Quinn lost the Joker forever!!!#Harley Quinn #joker
00:19
Harley Quinn with the Joker
Рет қаралды 20 МЛН
My Cheetos🍕PIZZA #cooking #shorts
00:43
BANKII
Рет қаралды 20 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 4 МЛН
Design Patterns in Plain English | Mosh Hamedani
1:20:01
Programming with Mosh
Рет қаралды 1,3 МЛН
Garbage collection in Java, with Animation and discussion of G1 GC
44:20
Ranjith ramachandran
Рет қаралды 486 М.
HashTable vs HashMap vs Concurrent HashMap all kinds of Map implementations
41:26
Design Patterns - An introduction
56:43
in28minutes - Get Cloud Certified
Рет қаралды 383 М.
Design Patterns for Beginners - New Version
45:49
in28minutes - Get Cloud Certified
Рет қаралды 156 М.
Singleton Design Pattern in Java - part I
26:25
Ranjith ramachandran
Рет қаралды 137 М.
Strategy Pattern - Design Patterns (ep 1)
35:11
Christopher Okhravi
Рет қаралды 1,4 МЛН
Equals and hashcode contract
13:50
Ranjith ramachandran
Рет қаралды 86 М.
Singleton design pattern in Java - Part 2
33:00
Ranjith ramachandran
Рет қаралды 62 М.
Design Patterns Introduction
5:57
Ranjith ramachandran
Рет қаралды 18 М.
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 33 МЛН