0

I found this page: https://stackoverflow.com/a/16910876/1254725.

THe implemented factory of this page is able to create the "Car" object, but also all of its dependencies :

static class CarFactory
{
    public ICar BuildCar()
    {
        Engine engine = new Engine();
        SteeringWheel steeringWheel = new SteeringWheel();
        Tires tires = new Tires();
        ICar car = new RaceCar(engine, steeringWheel, tires);
        return car;
    }   
}

What do you think about it?

Ben

Community
  • 1
  • 1
  • 1
    As long as it serves its responsibility (i.e creating cars), it's okay – Yang Jan 16 '15 at 13:39
  • 1
    If there is no other place where you need to create car's parts: Engine, SteeringWheel, Tires then it's OK for me. If not, then the part should have seperate factory which can be injected to CarFactory – Jakub Filipczyk Jan 16 '15 at 13:59

0 Answers0