Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 698 Bytes

singleton-details.md

File metadata and controls

25 lines (17 loc) · 698 Bytes

Singleton Pattern

Definition

Singleton is a creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance.

Purpose

To have only one instance of this object in the application that will handle all calls.

Example:

DB Connector
Logger
Lock file for the application

Abstract example

A country must have only one government or president. Through many members are formed the government. So the government or the president of any country like Singleton pattern.

Diagram Example

source : online

Code Example

(Example )