architect-handbook

Software Architect Handbook

View on GitHub

Registry

A well-known object that other objects can use to find common objects and services.

Overview

You may know an object’s ID number but not have a reference. A Registry acts as a global object (or at least looks like one) and provides finder methods.

How It Works

Interface

Implementation

You should consider data’s scope. Different scopes call for different implementations,.

Some applications may have a single Registry; some may have several. Registries are usually divided up by system layer or by execution context.

When to Use It

You should only use a Registry as a last resort, because despite the encapsulation of a method, a iRegistry is still global data.

There are alternatives: