Design Pattern

What is a Design Pattern?

Wikipedia currently defines a design pattern as ” is a general reusable solution to a commonly occurring problem within a given context“. what does that mean? As a developer we frequently need to save the same problem repeatedly. Such as how ton only have one of a class of an object in the application. Rather than have everyone come up with their own solution, we wuse a best practice type solution that has been documented and proven to work. the word generel is important. We can’t just copy and paste a desgign pattern into our code. It’s just an idea. We can write an implementation for it and put that in our code.

Using a design pattern has a few advantages. We get to use a solution that is kown to work.It also serve as communication aid.

Singleton Design Pattern :

the singleton design pattern ensures we only one instant of a class of an object within the application. It’s called a creational design pattern because it deals with creating objects.

Let’s improve more the singleton design pattern with a simple application in Eclispe :

1

Create a class Application to excute the class Singleton :

2

Execute the Application :

3

Leave a comment