The Data Access Object (DAO
) pattern abstract away the details of persistence in an application. Instead of having the domain logic communicate directly with the database, file system, web service, or any other persistence mechanism : The domain logic speaks to a DAO layer instead. This DAO layer then communicates with the underlying persistence system or service.
The advantage of the DAO
layer is that if you need to change the underlying persistence mechanism you only have to change the DAO layer, and not all the places in the domain logic where the DAO
layer is used from.
Look at this article for better understanding.
In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.
The client needs a product, but instead of creating it directly using the new operator, it asks the factory object for a new product, providing the information about the type of object it needs.
The factory instantiates a new concrete product and then returns to the client the newly created product(casted to abstract product class).
The client uses the products as abstract products without being aware about their concrete implementation.
Read this article for better understanding.
Factory pattern talks about creation of object & DAO patterns talks about management of data