This commit is contained in:
Ilkka Seppälä
2019-12-13 21:09:28 +02:00
parent 0335c61512
commit b2b1ba95eb
127 changed files with 282 additions and 450 deletions

View File

@ -5,9 +5,7 @@ folder: singleton
permalink: /patterns/singleton/
categories: Creational
tags:
- Java
- Gang Of Four
- Difficulty-Beginner
---
## Intent
@ -54,14 +52,14 @@ assertEquals(enumIvoryTower1, enumIvoryTower2); // true
## Applicability
Use the Singleton pattern when
* there must be exactly one instance of a class, and it must be accessible to clients from a well-known access point
* when the sole instance should be extensible by subclassing, and clients should be able to use an extended instance without modifying their code
* There must be exactly one instance of a class, and it must be accessible to clients from a well-known access point
* When the sole instance should be extensible by subclassing, and clients should be able to use an extended instance without modifying their code
## Typical Use Case
* the logging class
* managing a connection to a database
* file manager
* The logging class
* Managing a connection to a database
* File manager
## Real world examples