Component Inheritance
Component Inheritance is one of the principles of Component-Oriented Programming (COP) supported by Atmos.
Component Inheritance is the ability to combine multiple configurations through ordered deep-merging of configurations. The concept is borrowed from Object-Oriented Programming to logically organize complex configurations in a way that makes conceptual sense. The side effect of this are extremely DRY and reusable configurations.
In Object-Oriented Programming (OOP), Inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation.
Similarly, in Atmos, Component Inheritance is the mechanism of deriving a component from one or more base components, inheriting all the properties of the base component(s) and overriding only some fields specific to the derived component. The derived component acquires all the properties of the "parent" component(s), allowing creating very DRY configurations that are built upon existing components.
Component Inheritance is implemented and used in Atmos by combining two features: import
and metadata
component's configuration section.
- Base Component is an Atmos component from which other Atmos components inherit all the configuration properties
- Derived Component is an Atmos component that derives the configuration properties from other Atmos components
Single Inheritance
Single Inheritance is used when an Atmos component inherits from another base Atmos component.
In the diagram below, ComponentA
is the base component. ComponentB
and ComponentC
are derived components, they inherit all the
configurations (vars
, settings
, env
and other sections) from ComponentA
, and can override the default values from ComponentA
.