What is the difference between factory design pattern and DAO design pattern

Comparing these two patterns - Factory and DAO, I see that they are very similar:

Both have an interface ( Product/Dao), Factory ( ProductFactory/DaoFactory) and a specific implementation ( ConcreteProduct,ConcreteDao).

Factory creates some specific implementation object, and this object is used by the client through the interface.

So are they alike or am I not understanding something? Or maybe the Dao pattern is a concrete implementation of the Factory pattern?

Thanks in advance.

+4
source share
4 answers

Data Access Object (DAO) . , , , - : DAO. DAO .

DAO , , DAO, , DAO.

.

Factory pattern , , .

, factory , .

factory , ( ).

, .

.

Factory DAO

+1

DAO ( sql) Java

, a Factory , . , , SocketHandlerFactory, ServerSocket, , , Socket , Factory.

?

+1

, DAO, - :

enter image description here

DAO . , Spring Repositories DAOs, , .

Oracle, , GoF factory ( " " 2: " factory factory))

The DAO pattern can be made highly flexible by adopting the Abstract Factory [GoF] 
and the Factory Method [GoF] patterns (see "Related Patterns" in this chapter).

, , , factory DAO- "" factory , , .

+1

, .

DAO .

Fatory .

Don't worry about implementation / interface details.

Separate your application into layers, and if you need a database, then if the DAO is one of the options that can be used for different layers.

0
source

Source: https://habr.com/ru/post/1609681/


All Articles