Lecture overview -- Keyboard shortcut: 'u'  Previous page: Object-oriented Design Patterns -- Keyboard shortcut: 'p'  Next page: A Singleton Random Class -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Reference types, Value types, and Patterns - slide 25 : 29

The Singleton pattern

Problem: For some classes we wish to guarantee that at most one instance of the class can be made.

Solution: The singleton design pattern

singleton.cs
A template of a singleton class.
singleton-die.cs
A singleton Die class.
dieApp.cs
Application of the singleton Die class.
output
Output of singleton Die application.

A singleton Die is - most probably - not very useful.

On the next slide we will show a singleton Random, which solves a real problem