The real life analogy of a Prime minister having a PA schedule all his appointments was wonderful, helped understand Singleton concept a tad better 🙂
@sudocodeАй бұрын
Glad you liked it @aishwarya8283
@ThilankaDilshanHerath6 ай бұрын
Spent Hours and hours to learn the concepts. Finally I found my peace. Thank you very much . Great Stuff!
@yaad1222 жыл бұрын
Well Done and keep it up, I am improving day by day by watching all these great videos.
@sudocode2 жыл бұрын
Glad to hear that
@syit_346_adityaprajapati6 Жыл бұрын
you are the best for DP lectures
@Sdirimohamedsalah Жыл бұрын
Smooth explanation thank you. I have tow questions 1- a singleton pattern save memory ? 2- could you please illustrate the last point how can we get unwanted behavior without using thread safe ?
@jatindersinghaujla2 жыл бұрын
Great, very nice well informative video on design patterns. You guys make our learning more easier after watching these video I believe there is no need to read books. I am following you guys from 1 year almost and I have learnt a lot more from you, Gaurav sen, Kirti Purshwani, Kunal Kushwaha, Apna College guys and other. Keep on doing such a great work to teach us. Really appreciate your hard work.
@jeevan2Ай бұрын
amazing video
@BhooshanMusic25 күн бұрын
singleton implementation part is Java heavy . But love the rest of the series : It is serving as a great resource to me!
@lapimpale2 жыл бұрын
Thank you for eager loading and lazy loading. After watching multiple singleton videos I was confused why there was difference. I thought it was just coding style of that individual so never googled it too. Now I am clear :) and can also explain interviewer.
@sudocode2 жыл бұрын
Great to hear!
@rahul-sinha2 жыл бұрын
Great mam, please add here more videos on other design patterns as well. Thank you 😊👌
@sudocode2 жыл бұрын
I will try my best. Some will be coming soon
@prashantrajawat28292 жыл бұрын
Mam please complete remaining video of solid principles. Your explanation is amazing 👍
@lettry52972 жыл бұрын
Your every video is worth to watch. Please keep on adding such high quality content. 🤩
@abhishekpatyal74802 жыл бұрын
Hi Yogita, Awesome video. Thank you so much for explaining the Singleton pattern so smoothly. However At 7:12, I think there is a slight correction to be made. I think the implementation is thread safe because we are creating the object as soon as application starts. So, it is thread safe.
@this.arunsaini2 жыл бұрын
right and with that ... last point of cons... the inconsistency part. If the singleton is initialized and more than one thread is using it then it will remain consistent since we cannot change the data after initialization.
@AbhishekKumar-yv6ih7 ай бұрын
Right, since we are not changing the data midway, reading through multiple threads won't take it to data inconsistency.
@saumitrasaxena84702 жыл бұрын
Hi ,Its good explanation and would appreciate if you would have shown like how initial code can be broken by refelction and then do the needful , and then like how code is not thread safe by generating two threads and changing value via threads.Hoping to see the same later videos
@ALLINONETV1 Жыл бұрын
Nice
@terex1394 Жыл бұрын
Great work
@rite2riddhi2 жыл бұрын
very nice video
@vinodrajj Жыл бұрын
Excellent !
@saumitrasaxena84702 жыл бұрын
Hi Yogita , This singleton class can be breaked using reflections.Also appreciate if you would have covered Reflection ,Cloning and Serialization which can break this Singleton contract.
@SankalpCollege-f2o10 ай бұрын
For Reflection, there is a snippet in the video where the constructor is throwing RuntimeException if anyone tries to be smart using Reflection.
@sanketh7682 жыл бұрын
We can declare logger as final, then nobody can change its value
@mdnadeemasgar6279 Жыл бұрын
Hi Yogita, can you please upload the code online and share the code url in the description. So that we can also try manipulating the code for the given design pattern.
@umeshnaik844 Жыл бұрын
Your videos are Dope
@harshi9939 ай бұрын
What do you mean by thread safety?
@santoshr42122 жыл бұрын
why would we have DB connection as singleton? are we going to use one open conn for all requests? If yes, is it ok to have a conn open?
@tolosricardos21112 жыл бұрын
thanks a lot for the video
@SS-sn4df2 жыл бұрын
why cant we use a "final" keyword to avoid overriding problem with the global variable?
@surya2192 жыл бұрын
How to book appointment of PM in the given example?
@chethan932 жыл бұрын
Consider PM's calendar is the object. Singleton pattern makes sure everybody gets a common instance of it. Then the calendar can have methods to book slots in it. Booking slots must also be synchronised here.
@himeshgupta64787 ай бұрын
Can we make the global variable final in Java that solves the issue of getting it updated? Also why are we stressing about thread synchronisation when all the threads are going to read this variable once created no write updates allowed so no race condition
@soomann27163 ай бұрын
In lazy loading...any thread running will either create the object or use it.....Suppose two thread try to access the getInstance method at same time....without using synchronized...both will read instance==null so both will create new instance of class....but in synchronized it works like key and lock...if any thread goes inside synchronized it puts lock so that no other thread can get inside it...unless the thread has been completed and release the lock... Also feel free to correct me if I am wrong anywhere or ask any
@mysterionetwork78499 ай бұрын
When you say you have attached link in the description (here for volatile keyword) I am not able to find it, not sure if I am looking at the wrong place
@amanraut53042 жыл бұрын
👌👌👌👌👌👌
@kalyanroy66872 жыл бұрын
If a global variable is a const/final, it can't be modified
@rahultej8352 Жыл бұрын
❤❤❤
@terex1394 Жыл бұрын
🙏🙏🙏
@colinmaharaj Жыл бұрын
So I have been doing coding for over 20 years, but I never really understood design patterns. You mentioned thread safety as part of this Singleton pattern, but thread safety is a particular technique in coding, and syntax may vary between compilers. So how can this be part of a pattern? I'm now watching the whole video, I'll comment after watching in it's entirety.
@colinmaharaj Жыл бұрын
Interesting, there are many variables that I usually keep as global, e.g. company name, and the only time it is written to is during application startup or during a config form dialog. During configuration , a multi threaded report, or a multithreaded schedule can kick in, and do a read-only on the variable. I do not have many writers for this variable, and only one person is allowed to configure the app. In my humble opinion, I will not do a singleton factory for that one variable, in fact I have hundreds of global variables that represents settings in my application, and the principle remains the same, only the configuration screens are allowed to write to these variables, or the first time loading process. So I think it is overkill to create a singleton factory to serialize access per variable. I am not saying the concept is bad or useless It's just appears to me to be overkill for hundreds of my variables because of the way my app will access them. Note that I use C++ Builder with 32 bit compiler turned on. I will do a 64 bit CLANG compiler from time to time. Now I do have routines, that is doing low level communications to a serial port or to a tcp socket. There is a reader routine and a writer routine. The writer routine, runs in a thread and waits for data from the serial port or tcp socket. These operations are usually blocking, so this is why I placed them in a thread. The fore-ground application, reads data from blocks of memory, that the writer writes to. In cases like these, I have a serializing agent, to make the writes and reads thread safe. There is only one writer and there is only one reader. The data structure that is being written to is a circular buffer. The writer will make the buffer length grow, and reader will make the buffer length reach to zero. Very recently, I wrote a process calling agent, to monitor an application called plink. The idea was to take the output of plink and have it write to my thread safe circular buffer. My fore ground routine would see if there is data in the buffer, empty the buffer and print it to the screen. If no data is produced within a period of time, the called process, plink, is killed. There is a situation where plink appears to hang, without any output being created, and does so indefinitely. So in this case I use my thread safe circular buffer to get data from plink. Plink is an ssh console app that writes to the screen. Once plink finishes within a reasonable time, the application closes itself, and the process handler is released. If plink appears to hang, my calling process kills the app and prints an error to the screen.