How do I create instances of classes which require a huge amount of components and attributes? Take for example a car. A car has hundreds of sub components each with their own specific properties. There would be thousands of parameters to pass or work with. Some components even repeat themselves inside of the car (wheels, doors, brakes, springs, etc). I made two demo Car classes and I came up with two ways of initializing them. I am not happy with either.
First Way: Nest all of the subclasses and initialize the car with a huge statement. I don't like this because I cannot create sub components first and slowly build. What if I don't know how big the wheels are going to be, what do I do? Do I need to specify defaults? What If I need multiple doors? Would this be usable if the class actually needs thousands of arguments like a real car would?
Class Car(Size, TireType, Displacement, Cylinders, ECU, Fuel Type, PowerLockButton, Gears, ShiftLeverLength, ClutchType, GearKnob, Computer, TorqueConverter, FluidType, Links, SpringRate, BushingMaterial, ShockType)
Class Wheels(Size, TireType)
Class Engine(Displacement, Cylinders, ECU, Fuel Type)
Class Door(PowerLockButton)
Class Transimission(Gears)
Class ManaulTransmission Inherits From Transmission(ShiftLeverLength, ClutchType, GearKnob)
Class AutomaticTransmission Inherits From Transimission(Computer, TorqueConverter, FluidType)
Class Suspension(Links, SpringRate, BushingMaterial, ShockType)
FordMustang = Car(20", Michelin, 5.0L, 8Cylinders, Delphi, Gasoline, NoPowerLock, 6Gears, 3inches, SportClutch, MetalKnob, StiffLinks, 550lbRate, PolyUrethaneBushing, MagneticShocks)
BMW530i = Car(18", Continental, 3.0L, 6Cylinders, Bosch, Gasoline, YesPowerLock, 6Gears, BoschTransComputer, MediumTorqueConverter, ExpensiveFluid, ModerateLinks, 45lbRate, RubberBushing, SachsShocks)
Second Way: Create the Car component classes and then aggregate them all into a Car Class. I don't like this because I have to use many lines of code to build the car and that code seems orphaned sitting out in the open. Also, I am never going to use any of these components (wheel, engine, transmission, etc...) in anything other than inside of a car, so why leave them outside of the scope of the car class?
Class Wheels(Size, TireType)
Class Engine(Displacement, Cylinders, ECU, Fuel Type)
Class Door(PowerLockButton)
Class Transimission(Gears)
Class ManaulTransmission Inherits From Transmission(ShiftLeverLength, ClutchType, GearKnob)
Class AutomaticTransmission Inherits From Transimission(Computer, TorqueConverter, FluidType)
Class Suspension(Links, SpringRate, BushingMaterial, ShockType)
Class Car(Wheels, Engine, Door, Transimission, Suspension)
BMW530iWheels = Wheels(18', Continental)
BMW530iEngine = Engine(3.0L, 6Cylinders, Bosch, Gasoline)
BMW530iDoor = Door(YesPowerLock)
BMW530iTransmission = AutomaticTransmission(6Gears, BoschTransComputer, MediumTorqueConverter, ExpensiveFluid)
BMW530iSuspension = Suspension(ModerateLinks, 45lbRate, RubberBushing, SachsShocks)
BMW530i = Car(BMW530iWheels, BMW530iEngine, BMW530iDoor, BMW530iTransmission, BMW530iSuspension)
Any insight on how this can be done reliably? My concern is that either way I pick will become overwhelming to use when the number of attributes is extremely high. What ever you can contribute will be greatly appreciated.