|This page is under construction|
Please help review and edit this page.
The storage layer (or persistence layer) is responsible for storing and retrieving application entities. It provides an abstraction layer encapsulating the underlying storage technologies, such as databases. It creates the underpinning for application logic in higher layers, especially in the behavior layer.
Encoding and decoding domain "nouns" (as defined in the entity layer) is an essential part of the storage layer's responsibility. However, it should be noted that this encoding should be considered separate from the one used for communication in the API layer.
Ideally, the storage layer hides all details of the storage mechanism, allowing the underlying storage technology to be replaced without any impact on the application logic that builds on top of the storage layer.
As per August 2020, the idea of a storage layer is well established, especially in the form of data access objects. However, quite a bit of code in the user interface layer still interacts with the underlying database directly, bypassing the storage layer. In addition, some storage abstraction is encoded using the deprecated active record pattern.
Code in the storage layer should not make use of code in layers above it, such as the processing layer, the behavior layer or the user interface layer. In particular, it should not make use of localization, though it may apply internationalization.
Code in the behavior layer may depend only on code in libraries and the value layer.
The preferred pattern for storage abstraction is the data access object pattern.
An example of storage layer code is the