Which two valid alternatives to line 3 would decouple this application from a specific implementation of customerDAO?

Given the fragment:
<code>
public class CustomerApplication {
public static void main (String [] args) {
CustomerDAO custDao = new CustomerDAOMemoryImp1 ();
// . . . other methods
}
}
</code>
Which two valid alternatives to line 3 would decouple this application from a specific
implementation of customerDAO?

Given the fragment:

public class CustomerApplication {
public static void main (String [] args) {
CustomerDAO custDao = new CustomerDAOMemoryImp1 ();
// . . . other methods
}
}

Which two valid alternatives to line 3 would decouple this application from a specific
implementation of customerDAO?

A.
CustomerDAO custDao = new customerDAO();

B.
CustomerDAO custDao = (CustomerDAO) new object();

C.
CustomerDAO custDao = CustomerDAO.getInstance();

D.
CustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1();

E.
CustomerDAO custDao = CustomerDAOFactory.getInstance();

Explanation:

Note: Data Access Layer has proven good in separate business logic layer and persistent layer.
The DAO design pattern completely hides the data access implementation from its clients. The
interfaces given to client does not changes when the underlying data source mechanism changes.
this is the capability which allows the DAO to adopt different access scheme without affecting to
business logic or its clients. generally it acts as a adapter between its components and database.
The DAO design pattern consists of some factory classes, DAO interfaces and some DAO classes
to implement those interfaces.



Leave a Reply 0

Your email address will not be published. Required fields are marked *