What's the difference between Singleton and Registry design pattern

Both are about instance control. The difference is that Singleton allows only one instance of a given class while Registry holds a 1-1 map of keys to instances. Typically, the key is (or represents) a class and the value is an instance of that class.

For example, Code Igniter framework holds a registry with an instance of each library/model/controller/helper you load and returning those same instances every time.


A Registry differs in that its principal purpose is to allow you to navigate to associated objects. See Martin Fowler.


The main difference between registry and singleton is that singleton allow us to create a single instance of a class at a time, whereas registry allows us to create multiple instance of the same class.