Re: Retrieving unnecessary data
- From: Jordan Marr <jnmarr@xxxxxxxxxxx>
- Date: Thu, 21 Feb 2008 08:46:42 -0800 (PST)
C) Remove the passengers field, and retrieve them with another call.
That's closer. You should *hide* all the fields, and retrieve them
whenever you need them.
I'd call GetCar(), and then if I want the passenger list, I'd call
GetPassengers(Car);
Or rather, car.GetPassengers();
It seems to me that more information is required to better answer this
question.
Imagine if, for example, the OP only needed passenger information if
the car was a "BMW", and he is looping through 1000 cars:
foreach (Car car in cars) {
if (car.Make == "BMW")
Console.Write( car.GetPassengers().Count );
This could cause *many* expensive web service calls!
D) Make 2 classes - Car and CarWithPassengers (that can derive from
Car).
We shot those people too.
If they are used in different use cases, why not subclass car just for
this use case? I think it would be a better alternative than lazy
loading since the OP is using expensive web service calls (see above).
Jordan
.
- Follow-Ups:
- Re: Retrieving unnecessary data
- From: topmind
- Re: Retrieving unnecessary data
- References:
- Retrieving unnecessary data
- From: ShaneLM
- Re: Retrieving unnecessary data
- From: Robert Martin
- Retrieving unnecessary data
- Prev by Date: Re: Translation
- Next by Date: Re: Retrieving unnecessary data
- Previous by thread: Re: Retrieving unnecessary data
- Next by thread: Re: Retrieving unnecessary data
- Index(es):
Relevant Pages
|