What should you do?

You are an enterprise application developer. You are implementing a new component for an application. The component accesses a database to populate a list of customer objects and exposes a method that is named GetAllCustomers. The component uses a design pattern to access the database only on an as-needed basis. A caching mechanism exists in a lower tier of the application architecture. The component must not cache data. You need to implement the logic for populating a list of customer objects by using a database query. You also need to ensure that you meet the company guidelines for the component design pattern. What should you do?

You are an enterprise application developer. You are implementing a new component for an application. The component accesses a database to populate a list of customer objects and exposes a method that is named GetAllCustomers. The component uses a design pattern to access the database only on an as-needed basis. A caching mechanism exists in a lower tier of the application architecture. The component must not cache data. You need to implement the logic for populating a list of customer objects by using a database query. You also need to ensure that you meet the company guidelines for the component design pattern. What should you do?

A.
Execute a query in the constructor of the component to populate a field of type List<Customer>. Return the List reference in the call to the GetAllCustomers method.

B.
Execute a query in the static constructor of the component to populate a static field of type List<Customer>. Return the List reference in the call to the GetAllCustomers method.

C.
Execute a query in the GetAllCustomers method to populate a local variable of type List<Customer>. Return the List reference.

D.
Execute a query in the GetAllCustomers method to populate a field of type List<Customer> only if the field is null. Return the List reference.



Leave a Reply 0

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