Detailed examples of Java design pattern (DAO)
Detailed examples of Java design pattern (DAO)
Application scenario: in Java programs, it is often necessary to persist data and obtain persistent data, but there are many problems in the process of data persistence (such as different data sources, different storage types, different suppliers, different access methods, etc.). How can data persistence be operated with a unified interface?
In fact, I don't have a student number (R n q). My understanding is that a product is not aimed at a single user, so we should be compatible with many situations, such as different data sources, different storage types, different suppliers, different access methods, etc.
★ solution
Understanding of Dao:
1. Dao actually uses the combined factory model to solve problems, and does not bring new functions, so learning is actually an idea. 2. Theoretically, there is no limit on the number of layers of Dao. 3. Theoretically, there is no sequence of layers of Dao.
There are three types of project files:
Some code implementation
Interface
Factory method (multiple alternative implementations)
There are several factories with similar methods, so they don't post them
Implementation class
If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!