Tag archive for: Java programming

Ways to implement the Singleton pattern in Java

After you got started with Java programming, chances are you will want to use some design patterns to organise your Java classes.

One common object oriented design pattern is the Singleton pattern. The Singleton pattern is a technique where you can apply to ensure that there is only one instance of your Java class per runtime.

The Singleton pattern is usually used for grouping functionalities that allow callers to act on a single set of state. Examples of cases where the Singleton pattern can be applied include:

  • A class that keeps track of a customized configurations from a configuration file.
  • A class that facilitates interactions with a database system.
  • A class that performs logging.
  • A class that caches data read from previous database calls.

This post documents some ways to implement the Singleton pattern in Java.


Books that helped me understood Java and became proficient in it

The Java programming language had opened up a lot of opportunities for me ever since I was acquainted with it. Most people say that learning Java is easy, however mastering it is hard. For me, mastering Java could have been harder if not for some of the books that I had read. In this post, I list some of the books that had taught me a great deal of Java, so much so that I am able to be proficient with it.