Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Opinions and conventions

I am restructering some of my code, and i have a question about some conventions and/or opinions on the "best" way of doing the following.

I have some entity classes such as "Customer", "Product" etc, and some database access classes such as "CostomerDataProvider", "ProductDataProvider" etc.

Which of the following is a better or conventional way for retrieving information from the database?

Customer aCustomer = new Customer(strCustomerID);
CustomerDataProvider custDP = new CustomerDataProvider();
custDP.GetCustomer(aCustomer) // fills the customer object
... some code later
CustDP.UpdateCustomer(aCustomer);

OR

CustomerDataProvider custDP = new CustomerDataProvider();
Customer aCustomer = custDP.GetCustomer(strCustomerID)
...some code later
custDP.UpdateCustomer(aCustomer);

In other words, the updating of data will be supplied an "Entity" class containing the data to update, but should the data retrieval methods be supplied the ID or should they be supplied an "Entity" class with its ID property set? I want things consistant and conventional.

THanks :D
[1163 byte] By [blackettle76] at [2007-11-11 10:17:03]