Sunday 30 November 2014

What is design pattern in java?

design pattern in java

Design Pattern  :



Design pattern are  answer to common occurring problem in software system development . Design pattern are language independent solution that are developed to solve common object oriented issues .
They if used sensibly helps to extend code maintainability , reduces learning curve whereas developing a bit of code ,makes development quicker ,reduces TCO (total value  output) and helps to simply understand solution to new developer.


Singleton Design Pattern :
Singleton Design pattern uses a singleton class which should have a single instance.
Singleton design pattern ensures that at a single point of time only a single instance should be present in JVM Singleton class should also provide a method which acts as a single point for global access of that class.

Common approach for a singleton pattern :
1. Singleton class should have a private constructor so that no other class can instantiate it .
2. Singleton class should have a private static variable of the class that will be the only instance of that class.
3. A public static method which is the only global access point for outer world.

You may like :
Difference between equals() and = =

No comments:

Post a Comment