Say I need car
object. Could you please tell about the scenarios in which one approach would be better than the other?
Method#1
CreateCar(engineType, carBodyDesign, color, otherconfiguration1,...,otherconfigurationN)
{
engine=MakeEngine(engineType);
body=MakeCarBody(carBodyDesign);
.
.
.
//assemble all parts here
return car;
}
Method#2
ModelNo
has the info about engineType
,carBodyDesign
, etc. color
, seatCoverColor
, etc info are absent.
CreateCar(ModelNo, color,otherconfiguration1,...,otherconfigurationN)
{
car=MakeCar(modelNo);
car.configurableItem1=MakeConfigurableItem1(otherconfiguration1);
.
.
.
car.configurableItemN=MakeConfigurableItemN(otherconfigurationN);
return car;
}
Aucun commentaire:
Enregistrer un commentaire