The Game Panel specification

ADR-0005: Configuration is held in typed objects

Context

The engine’s components need configuration, and so do modules. The code that consumes a configuration needs to rely on its shape and on the types of its values.

Decision

Each configuration is an instance of a class unique to that configuration, registered against a module and a name. Its values are typed properties, and it may contain child objects, so the shape and types of a configuration are enforced by its class rather than by the code that reads it. A configuration object is found by its module and name, or by its class, and a component receives the one it needs by its class.

Alternatives

Whether anything was weighed against typed objects is not recorded. Configuration held in arrays read by key is the obvious other option, and gives no type safety, since nothing enforces the shape of an array or the types of its values, but nothing records it being considered.

Consequences

Easier:

Harder:

Constrained:

Sources