Re: Retrieving unnecessary data



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



.



Relevant Pages

  • Re: Retrieving unnecessary data
    ... Imagine if, for example, the OP only needed passenger information if ... the car was a "BMW", and he is looping through 1000 cars: ... loading since the OP is using expensive web service calls. ... OOP is generally overkill for task-oriented design because we are not ...
    (comp.object)
  • Re: Great SF predictions
    ... When I said a robocar would be programmed to not "overdrive" its ... That means you're going to have a very big gap between each car, ... closer following distance. ...
    (rec.arts.sf.written)
  • Re: Times article re: urban cycling and heart disease
    ... and I'd be guessing that the pollution gets worse the closer you ... A car air intake is also positioned rather closer to the exhaust ...
    (uk.rec.cycling)
  • Re: Series?
    ... I noted somethign strange between his two ... Closer still and I had to laugh. ... Lake, they might have been real bull testicles) right in the centre of the ... I've seen those - they're sold as a car ornament. ...
    (rec.arts.mystery)
  • Re: UK FUEL
    ... Use public transport or car share? ... Public transport isn't an option - it is impossible for me to get to ... Options include move closer to work, ... I have to be in London on Sunday next for a meeting - ...
    (uk.tech.digital-tv)