@zck7 I'll fill out my reply from the Observer video. The whole idea about a pattern is to identify components which are often found together to solve a certain problem. Many would argue that a single person does not invent a pattern, but recognizes its use in many places. So it is very common for programmers of different languages to come up with a same solution, but each with different names. In the case of the Observer, no name could have made everyone happy because many already existed.
Singletons are an anti-pattern; a recurring solution that while superficially attractive usually leads to worse design.
Singletons frequently make testing a head ache and compromise both the modularity and the 'modelarity' of the code(the degree of correspondence between the components of the problem being modelled and the components of its solution), harm encapsulation, make code difficult to evolve and extend.
The PfA pattern is often a good anti-dote to singletons.
Some ideas: Show the patterns you're explaining with a computer screen capture (most people prefer that over watching someone speaking into the camera) and also cut all the useless personal information. Keep making the videos :)
Try to rehearse your explanation before filming too :)
question, i like your video i was wondering if u can help me with a question i came up with an idea lets say there are two pc's ,in pc 1 there are three box's that are out putting letter from a-z box=f box=r box=w the next set of boxs box=h box=l box=x box 2 a-z box-3 a-z is it possible to see what pc 1 is out puting then take that info and manually in put it into pc 2 then could pc 2 know where pc 1 is going and what pc 1s next out put would be before it comes out
Singleton is the most well known anti pattern in OO. Please dont encourage it. Plus the example of db pools is shit, what happens when you want to employ diffent strategys in different environements, or mock the behaviour?
Yes, I indeed didn't mention that. However, this is an introduction for those who haven't yet been introduced to design patterns, so I'm keeping it simple. The wikipedia entry I refer to has a wide range of solutions for all kinds of languages, including a few multi-thread safe ones for java. I hope you find what you need there.
@codingkriggs I still am unable to get why would you need a Singleton when you can do the same thing with any class with all the static methods and with a private constructor meaning that no instantiation is possible. Example: public class ConPoolFactory{ private map pool = ... static{ //init } private ConPoolFactory public static Connection getConnection(){ } } And if you want instance's properties, you can grab them with public static getter methods. What can be wrong with this?..to be cont
@getalifein My favourite reason for singleton is extensibility through polymorphism. I can have an interface IManager, then a default implementation ManagerImpl, with a single instance accessed through ManagerImpl.getInstance(), for example, and then pass that around to other methods as a parameter. Another developer could implement their own AlternateManager implementing IManager, and so the called method would be unaware which implementation they're receiving, improving extensibility.
If you implement a singleton in Java please dont do the assignment of your singleton variable in the constructor. This is an unneccessary waste of resources (check for null every time you want to get your singleton). Do it at its declaration. This also prevents you from synchronizing access to the singleton to make it threadsafe.
Singleton is EVIL PATTERN!
BrooKlynEMol 1 month ago
@Thetranslatorguy I take it you're being purposefully confusing.
codingkriggs 5 months ago
I and others always called this a one-time-only initialization. I don't see the need for giving it a new name "Singleton".
zck7 7 months ago
@zck7 I'll fill out my reply from the Observer video. The whole idea about a pattern is to identify components which are often found together to solve a certain problem. Many would argue that a single person does not invent a pattern, but recognizes its use in many places. So it is very common for programmers of different languages to come up with a same solution, but each with different names. In the case of the Observer, no name could have made everyone happy because many already existed.
codingkriggs 7 months ago
@zck7 He didn't give it a new name...
Poskusin 4 months ago
Singletons are an anti-pattern; a recurring solution that while superficially attractive usually leads to worse design.
Singletons frequently make testing a head ache and compromise both the modularity and the 'modelarity' of the code(the degree of correspondence between the components of the problem being modelled and the components of its solution), harm encapsulation, make code difficult to evolve and extend.
The PfA pattern is often a good anti-dote to singletons.
soylentgreenb 1 year ago
oh my god! wtf? this is a waste of time.
ditsaa 1 year ago
This has been flagged as spam show
get some sun geek
bytedildo 1 year ago
Comment removed
a0102294421 1 year ago
Some ideas: Show the patterns you're explaining with a computer screen capture (most people prefer that over watching someone speaking into the camera) and also cut all the useless personal information. Keep making the videos :)
Try to rehearse your explanation before filming too :)
Peaceguard 1 year ago
This has been flagged as spam show
manattan342 1 year ago
You're such a typical newb; learn something new and you're suddenly an expert on the subject.
mahcuz 2 years ago
he said LIE-BARRY at 1:24. ouch
dittonamed 2 years ago
Singleton is the most well known anti pattern in OO. Please dont encourage it. Plus the example of db pools is shit, what happens when you want to employ diffent strategys in different environements, or mock the behaviour?
Singleton == SHITE
kinkokonko 2 years ago
waste of time , this guy is so close to the monitor
polehole234 3 years ago
The Object Singleton will not dispose until program exit. why because of using 'STATIC'
how we can assure that this class will not instantiate by another object?
NOTICE the "PRIVATE Constructor" he wrote of a "Singleton CLASS"
but not recommend this in the multithreading.
jinfrics 3 years ago
Learn. English.
mahcuz 2 years ago
You forgot to talk about the singleton in a multi-threaded environment. If you don't do it properly, you will get multiple instances!
gamccoy 4 years ago
Yes, I indeed didn't mention that. However, this is an introduction for those who haven't yet been introduced to design patterns, so I'm keeping it simple. The wikipedia entry I refer to has a wide range of solutions for all kinds of languages, including a few multi-thread safe ones for java. I hope you find what you need there.
codingkriggs 4 years ago
getalifein 10 months ago
@codingkriggs - ....(cont).. and if it can work fine, then WHERE is the usage of ONE OFF instantiation.
I am confused.
Thanks for the video by the way.
getalifein 10 months ago
@getalifein My favourite reason for singleton is extensibility through polymorphism. I can have an interface IManager, then a default implementation ManagerImpl, with a single instance accessed through ManagerImpl.getInstance(), for example, and then pass that around to other methods as a parameter. Another developer could implement their own AlternateManager implementing IManager, and so the called method would be unaware which implementation they're receiving, improving extensibility.
codingkriggs 10 months ago
If you implement a singleton in Java please dont do the assignment of your singleton variable in the constructor. This is an unneccessary waste of resources (check for null every time you want to get your singleton). Do it at its declaration. This also prevents you from synchronizing access to the singleton to make it threadsafe.
gelien333 4 years ago
Amazingly... bad video. Ever heard of video editing? Noise removal in audio tracks?
BTW, singletons, java and paper code listings on video == pure evil.
h3r2tic 4 years ago
I find it original ! and kind !
johannazeul 4 years ago
nice explaination
ruiner2501 4 years ago
The behavior you mentioned at the beginning of the video is called procrastination (I'm actually very fond of it muehehe)
Nice video, very illustrative.
snt0 4 years ago