java - What is difference between factory design pattern and DAO design pattern -


comparing these 2 patterns - factory , dao patterns, see quite similar:

both of them have interface (product/dao), factory (productfactory/daofactory) , concrete implementation (concreteproduct,concretedao).

factory creates concrete implementation object , object used client via interface.

so similar or don't understand something? or maybe dao pattern specific implementation of factory pattern?

thanks in advance.

the data access object (dao) pattern abstract away details of persistence in application. instead of having domain logic communicate directly database, file system, web service, or other persistence mechanism : domain logic speaks dao layer instead. dao layer communicates underlying persistence system or service.

the advantage of dao layer if need change underlying persistence mechanism have change dao layer, , not places in domain logic dao layer used from.

look @ this article better understanding.

in factory pattern, create object without exposing creation logic client , refer newly created object using common interface.

the client needs product, instead of creating directly using new operator, asks factory object new product, providing information type of object needs.

the factory instantiates new concrete product , returns client newly created product(casted abstract product class).

the client uses products abstract products without being aware concrete implementation.

read article better understanding.

factory pattern talks creation of object & dao patterns talks management of data


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -