mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
968 B
968 B
| title | aliases | tags | |
|---|---|---|---|
| data-access-object | DAO, DAOs, Data Access Object |
|
Designing DAOs
- general rule: one DAO per "logical unit" of data access
- many DAOs are just for one class e.g.,
PatronDAO - some involve many classes
- things like header/lines objects are always managed together
- complex operations that join multiple tables or domain classes
- different use cases (features) use different sets of DAOs e.g.,
- add, find, edit patron ⇒
PatronDAO - lend items ⇒
LoanDAO,ItemDAO,PatronDAO
- add, find, edit patron ⇒
- object construction and deconstruction coded into DAOs
Multiple implementation of the same DAO
e.g.,:
PatronDAOinterfacePatronCollectionDAOclass for in memore dataPatronJdbcDAOclass for SQL databasesPatronCsvclass for CSV files- all classes implement the
PatronDAOinterface
Having these options allows you to easily switch between, dev, test, and prod, and privileged and non privileged access