Idiotic guide to Singletons

Just an idiotic post teaching you how to implement a singleton and other nonsense.

In software engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. (Wikipedia)

So basically , the simplest way to write a singleton in, let’s say.. Java , would be


public class Idiot extends Imbecile implements Stupidity{
    public static final Idiot instance = null;
    
    public Idiot getInstance(){
          if(instance == null) instance = new Idiot();
          return instance;
    }
    private Idiot(){
    }
    
/* NOTE: real life idiots are definitely not made by the Singleton Pattern... */
}

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s