Singleton Pattern - Design Patterns

Singleton Pattern - Design Patterns

Web Dev Simplified

5 лет назад

153,754 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

krzysiek bakowicz
krzysiek bakowicz - 12.08.2023 18:25

Nice explenation but... All the design patterns should be presented in TypeScript. The key words like private, public, static, protected are crucial in my opinion. On the other hand, Everyone who has the TS knowledge should handle to add TS to your's code :) Thank You!

Ответить
NalDitrin Martinho
NalDitrin Martinho - 21.04.2023 17:26

Can we say that some parts of state managers like Redux use the Singleton Pattern?
Just to make sure I understood the concept here...

Ответить
Rebel
Rebel - 08.04.2023 14:35

Incident implementation. It should just be a module, not a class.

Ответить
rahim co
rahim co - 08.03.2023 12:27

thanks a lot for your efforts , i really appreciate that

Ответить
Stéphane Baribeau
Stéphane Baribeau - 02.02.2023 05:22

The person that decided this needed to be called a "singleton pattern" wasted a lot of time...

Ответить
arya rifqi pratama
arya rifqi pratama - 04.01.2023 01:00

Singleton adalah 1 instance object sifatnya shared reaource sehingga bisa di pakai oleh object lain

Ответить
Peter Zeng
Peter Zeng - 17.12.2022 18:41

You are so handsome and smart. Clear explanation, thanks!

Ответить
ivan cai
ivan cai - 09.11.2022 07:04

Love this explanation

Ответить
Skittlz NT
Skittlz NT - 26.10.2022 19:46

Very well explained. Thank you 🙏🏾

Ответить
yahel abraham
yahel abraham - 12.10.2022 14:43

great explanation, thank you

Ответить
Aryan Kumar
Aryan Kumar - 30.09.2022 03:18

is there a video on Factory Design Pattern ?

Ответить
Timedog
Timedog - 24.08.2022 02:38

Isn't a database just a singleton? Its a shared resource that can be used by many other processes for different purposes, instead of each of those processes having their own separate set of data. Am I wrong, or do people that don't like singletons not like databases either?

Ответить
softwarePower
softwarePower - 31.07.2022 19:24

Can we use this instead of FancyLogger inside the constructor of FancyLogger?

Ответить
Anees Ahmad
Anees Ahmad - 31.07.2022 08:20

O hooo 1K to Million sub

😻

Ответить
Jo Singleton
Jo Singleton - 02.07.2022 04:19

Dope!

Ответить
Ann Gular
Ann Gular - 05.06.2022 22:31

Error: "To load an ES module, set "type": "module" in the package.json or use the .mjs extension."

Ответить
Peng Gao
Peng Gao - 15.01.2022 14:51

Hi Kyle, thanks for the video. I have a question regarding to this singleton pattern: what's the difference between using an instance 'logger' and using a 'static' class attribute in the class 'FancyLogger' to record the logs ?

Ответить
No Name
No Name - 05.11.2021 22:02

thanks, good, but not professional))

Ответить
Aya Bochman
Aya Bochman - 17.10.2021 11:18

Such a good example!! Thank you!

Ответить
Abhinav Patel
Abhinav Patel - 11.10.2021 01:29

so redux is singleton 🥲

Ответить
louay khammar
louay khammar - 03.10.2021 13:21

thanks

Ответить
yimin zhou
yimin zhou - 04.08.2021 03:35

you are so handsome

Ответить
Omar Abid
Omar Abid - 03.08.2021 20:27

Hi, The implementation looks good but In order to verify that the singleton implementation is working correctly you need to instantiate the FancyLogger twice, in your current implementation the constructor is called only once.

Ответить
Augis, Chadie Gil S.
Augis, Chadie Gil S. - 18.07.2021 06:04

Ответить
Jens Törnell
Jens Törnell - 16.05.2021 21:13

Is it a good idea to use singleton to simplify plugin methods, something like field.setValue(34); Then it's like a namespaced function where the plugin maker does not need to add new instances of the class.

Ответить
T Lev
T Lev - 21.04.2021 21:24

Great explanation, and thanks for the video, just have 1 question, is it really necessary to do this manipulations inside constructor, if we import instance of logger it will be same instance for any file because of modules that are singletones anyway? Just wondering why we really need that checks here?

Ответить
Ardhi Irfan Sya'bani
Ardhi Irfan Sya'bani - 15.04.2021 07:05

to the point and really understandable! love it! keep up those great contents!

Ответить
ButtKraken
ButtKraken - 14.04.2021 01:32

Thanks for such a great explanation!

Ответить
AcousticBruce
AcousticBruce - 05.04.2021 03:11

I paused video and tried something first and then I finished your video and saw it was much different.. Does anyone know the pros and cons of my version?

let L;

class Logger { ... }

if (!L) {
L = new Logger();
}
module.exports = L;


Is there something wrong with this version? I did this in Node and because Node caches all uses of require, I figured this was okay.

Ответить
Ziko
Ziko - 21.02.2021 23:11

You have got 0.1% dislikes on your video, that is insane.

Ответить
Aissa BOUGUERN
Aissa BOUGUERN - 20.02.2021 04:22

We can also create a singleton via a factory function instead of doing it inside class constructor.
That's much cleaner imo.

Ответить
Julescsv
Julescsv - 17.02.2021 23:38

Sometimes I wonder where I would be without you. 🙏🙏🙏

Ответить
Kaji Al-Mamun
Kaji Al-Mamun - 03.01.2021 19:18

khankir pola kisui boji nai

Ответить
Sam Ms7
Sam Ms7 - 10.12.2020 20:47

Now I know how mongoose works behind the scenes.

Ответить
Zum
Zum - 29.11.2020 05:46

holy shit 0 dislikes. imma dislike it ahahhaahah jk bro ur awesome

Ответить
Ahmed Boutaraa
Ahmed Boutaraa - 17.11.2020 23:08

.....

Ответить
Kallyan B. Roy
Kallyan B. Roy - 02.09.2020 10:18

Most of the NPM modules (major ones) uses this pattern, e.g: Mongoose. This pattern is one of the best if anyone is creating a library or something like that as you might need to output some debug information for the module. Great video thanks a lot....BTW thanks for changing your uniform

Ответить
Nabi Isakhanov
Nabi Isakhanov - 26.07.2020 22:00

Angular services are singleton by default, so I guess this pattern does have its niche

Ответить
Audiodrocher
Audiodrocher - 24.06.2020 13:58

Ohshhhh, this is llifechanging. Thanks a lot.

Ответить
Hugo Seleiro
Hugo Seleiro - 09.06.2020 16:19

Thank y

Ответить
Sean Kozlowski
Sean Kozlowski - 22.05.2020 14:21

Led Zeppelin

Ответить
Muhammad At Thariq Filardi
Muhammad At Thariq Filardi - 13.05.2020 19:41

your videos are awesome! thank you so much!!

Ответить
Karthik Kumaresan
Karthik Kumaresan - 03.04.2020 06:08

awesome videos!! Keep them coming

Ответить
Mahdi
Mahdi - 19.02.2020 23:34

What is strategy pattern? Make a video on this. Thanks

Ответить
Mahdi
Mahdi - 19.02.2020 23:33

Just wow! these days i was just looking for how to share class modules with other user objects. Just wow!

Ответить
Klaus Petersen
Klaus Petersen - 29.11.2019 00:30

Why export an instance variable? Wouldn't it be the same if first and second file just call new, which would return the same instance and then move Object.freeze into the constructor? Thinking it would be a cleaner solution

Ответить
Marcos Antonio Reyes Medina
Marcos Antonio Reyes Medina - 17.11.2019 18:37

Hi, very good video. We have always seen the "Singleton" pattern applied to a DB Connection class, what do you think ... do you think it is correct to apply it in this case?

Ответить
vinay yadav
vinay yadav - 13.11.2019 15:37

thank'u

Ответить