Registry Pattern
Motivation
To Create a well-known object that other objects can use to find common objects and services.
Summary
Very basic and classic pattern that suggest to have a central location for object of common interested.
A Registry is essentially a global object, or at least it looks like one even if it isn't as global as it may appear.
Registries are generally implemented as singleton.
It is not very much encouraged as it is also treated as Anti Pattern
When to Use
We should usually avoid using registry pattern because it violates encapsulation principle.
Registry should be only used when there is no other ways to share data in between the object of same scope.
Alternative to registry could be
Parent/Caller Context could be another alternative in which caller passed it own context (usually "this" pointer) to called function either via constructor or by adding an extra parameter to method being called)
Registry Scope
Visibility of Registry can be defined at different scopes depending upon requirement
Thread Scoped
Process Scoped
Application Scoped
System Scoped
Related Patterns
Inversion of Control : Used for dynamic configuration of object loading.
Service Locators : can use registry for mapping service metadata
Dependency Injection : Allow you to implement registry configuration out side application like configuration file.
References