- Java EE 8 Design Patterns and Best Practices
- Rhuan Rocha Jo?o Purifica??o
- 304字
- 2021-07-23 16:54:59
Explaining the concept of the data-access object pattern
In the business world, the application always needs to be integrated with the data source in order to read, write, delete, or update data. This data source could be a relational database, NoSQL database, LDAP (Lightweight Directory Access Protocol), or filesystem, for example. Each type of data source has its structure and has a complexity to connect to, read, and write data. These complexities shouldn't be exposed to business logic and instead should be decoupled from it.
The data-access object pattern is a pattern used to abstract and hides all access to data sources from the business tier. This pattern encapsulates all data-source access logic and its complexities from the business tier, decoupling all data-source access logic from it. If we then want to substitute the data source with another, we will only need to modify the code of the data-access object pattern, and this modification will not be visible on the business tier. The following diagram displays the data-access object pattern model:

In the preceding diagram, we have BusinessObject, which has the business logic; DAO, which has the data access logic; TransferObject, which is the object used to transfer; and data source, which is the external local where the data resides. When BusinessObject needs to access the data, it requests data from DAO. The DAO accesses the data source and reads the data, then returns the data to BusinessObject as TransferObject. Some developers and professionals think this pattern is only supposed to be used with relational databases and NoSql, but when our data source is a filesystem or another type of data persistence, we should also use DAO in order to promote the decoupling between business logic and persistence logic as well as to organize our code.
- Linux設備驅動開發(fā)詳解:基于最新的Linux4.0內(nèi)核
- 從零開始寫Linux內(nèi)核:一書學透核心原理與實現(xiàn)
- Linux從零開始學(視頻教學版)
- Arch Linux Environment Setup How-to
- 無蘋果不生活 OS X Mountain Lion隨身寶典
- RESS Essentials
- 網(wǎng)絡操作系統(tǒng)管理與應用(第三版)
- jQuery UI Cookbook
- Windows 8實戰(zhàn)從入門到精通(超值版)
- Linux網(wǎng)絡配置與安全管理
- 從實踐中學習Windows滲透測試
- Multi-Cloud for Architects
- Linux從入門到精通(視頻教學版)
- Linux系統(tǒng)安全:縱深防御、安全掃描與入侵檢測
- 再也不踩坑的kubernetes實戰(zhàn)指南