Story of Singleton Design Pattern and a Prime Minister | LLD Series | Low Level Design |

  Рет қаралды 29,773

sudoCODE

sudoCODE

Күн бұрын

Пікірлер: 46
@aishwaryas8283
@aishwaryas8283 2 ай бұрын
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
@sudocode Ай бұрын
Glad you liked it @aishwarya8283
@ThilankaDilshanHerath
@ThilankaDilshanHerath 7 ай бұрын
Spent Hours and hours to learn the concepts. Finally I found my peace. Thank you very much . Great Stuff!
@syit_346_adityaprajapati6
@syit_346_adityaprajapati6 Жыл бұрын
you are the best for DP lectures
@UECAshutoshKumar
@UECAshutoshKumar 27 күн бұрын
Thank you 🙏
@yaad122
@yaad122 2 жыл бұрын
Well Done and keep it up, I am improving day by day by watching all these great videos.
@sudocode
@sudocode 2 жыл бұрын
Glad to hear that
@BhooshanMusic
@BhooshanMusic Ай бұрын
singleton implementation part is Java heavy . But love the rest of the series : It is serving as a great resource to me!
@jatindersinghaujla
@jatindersinghaujla 2 жыл бұрын
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.
@lapimpale
@lapimpale 2 жыл бұрын
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.
@sudocode
@sudocode 2 жыл бұрын
Great to hear!
@rahul-sinha
@rahul-sinha 2 жыл бұрын
Great mam, please add here more videos on other design patterns as well. Thank you 😊👌
@sudocode
@sudocode 2 жыл бұрын
I will try my best. Some will be coming soon
@prashantrajawat2829
@prashantrajawat2829 2 жыл бұрын
Mam please complete remaining video of solid principles. Your explanation is amazing 👍
@saumitrasaxena8470
@saumitrasaxena8470 2 жыл бұрын
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
@Sdirimohamedsalah
@Sdirimohamedsalah 2 жыл бұрын
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 ?
@lettry5297
@lettry5297 2 жыл бұрын
Your every video is worth to watch. Please keep on adding such high quality content. 🤩
@sanketh768
@sanketh768 2 жыл бұрын
We can declare logger as final, then nobody can change its value
@abhishekpatyal7480
@abhishekpatyal7480 2 жыл бұрын
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.arunsaini
@this.arunsaini 2 жыл бұрын
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-yv6ih
@AbhishekKumar-yv6ih 8 ай бұрын
Right, since we are not changing the data midway, reading through multiple threads won't take it to data inconsistency.
@jeevan2
@jeevan2 Ай бұрын
amazing video
@vinodrajj
@vinodrajj Жыл бұрын
Excellent !
@ALLINONETV1
@ALLINONETV1 2 жыл бұрын
Nice
@terex1394
@terex1394 Жыл бұрын
Great work
@rite2riddhi
@rite2riddhi 2 жыл бұрын
very nice video
@amanraut5304
@amanraut5304 2 жыл бұрын
👌👌👌👌👌👌
@mdnadeemasgar6279
@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.
@saumitrasaxena8470
@saumitrasaxena8470 2 жыл бұрын
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-f2o
@SankalpCollege-f2o 11 ай бұрын
For Reflection, there is a snippet in the video where the constructor is throwing RuntimeException if anyone tries to be smart using Reflection.
@mysterionetwork7849
@mysterionetwork7849 10 ай бұрын
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
@umeshnaik844
@umeshnaik844 Жыл бұрын
Your videos are Dope
@tolosricardos2111
@tolosricardos2111 2 жыл бұрын
thanks a lot for the video
@harshi993
@harshi993 9 ай бұрын
What do you mean by thread safety?
@santoshr4212
@santoshr4212 2 жыл бұрын
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?
@SS-sn4df
@SS-sn4df 2 жыл бұрын
why cant we use a "final" keyword to avoid overriding problem with the global variable?
@rahultej8352
@rahultej8352 Жыл бұрын
❤❤❤
@himeshgupta6478
@himeshgupta6478 8 ай бұрын
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
@soomann2716
@soomann2716 3 ай бұрын
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
@MrCool-kf5ll
@MrCool-kf5ll 6 күн бұрын
Class cant be synchronised only function lavel or block lavel. check ✅ the audio.
@terex1394
@terex1394 Жыл бұрын
🙏🙏🙏
@surya219
@surya219 2 жыл бұрын
How to book appointment of PM in the given example?
@chethan93
@chethan93 2 жыл бұрын
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.
@kalyanroy6687
@kalyanroy6687 2 жыл бұрын
If a global variable is a const/final, it can't be modified
@colinmaharaj
@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
@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.
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 9 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,3 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,2 МЛН
5 Design Patterns Every Engineer Should Know
11:51
Traversy Media
Рет қаралды 942 М.
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19