Is it considered a good practice to pass the model class from e.g. the DAL to a threaded service class as 'information model'?
Example:
public class CarModel {
public string Name { get; set; }
public int AmountOfWheels { get; set; }
public Engine EngineDescription { get; set; }
}
public class Car {
public CarModel CarModel { get; set; }
public Car(CarModel model) {
this.CarModel = model;
Thread.Start(BrummBrumm);
}
private void BrummBrumm() {
// start the car
}
}
This example is made under the assumption that CarModel is a entity (e.g. to use with Entity Framework or any other repository/DAL) or a model class to use with UI, WebApi, WCF.. and Car is a class that resides as implementation in e.g. a Windows service.
Edit further code
public class CarManager {
public List<Car> Cars = new List<Car>();
public void Add(CarModel model) {
this.Cars.Add(new Car(model));
}
public void Remove(int id) {
...
}
}
... then what's with the example above? What if I don't just have cars, but also motorcycles? Wouldn't the example above create a lot of boilerplate code?