Added: 4 years ago
From: codingkriggs
Views: 20,471
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (28)

Sign In or Sign Up now to post a comment!
  • Singleton is EVIL PATTERN!

  • @Thetranslatorguy I take it you're being purposefully confusing.

  • 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 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.

  • @zck7 He didn't give it a new name...

  • 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.

  • oh my god! wtf? this is a waste of time.

  • Comment removed

  • 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 :)

  • You're such a typical newb; learn something new and you're suddenly an expert on the subject.

  • he said LIE-BARRY at 1:24. ouch

  • 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

  • waste of time , this guy is so close to the monitor

  • 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.

  • Learn. English.

  • You forgot to talk about the singleton in a multi-threaded environment. If you don't do it properly, you will get multiple instances!

  • 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
  • @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 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.

  • Amazingly... bad video. Ever heard of video editing? Noise removal in audio tracks?

    BTW, singletons, java and paper code listings on video == pure evil.

  • I find it original ! and kind !

  • nice explaination

  • 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.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more