class MyConcreteFactory
{
public static function create($model, $typeId)
{
if ($typeId == 'customer') {
return new CustomerWrapper($model);
}
if ($typeId == 'order') {
return new OrderWrapper($model);
}
if ($typeId == 'product') {
return new ProductWrapper($model);
}
}
}
How can i improve this? The main flaw is that managing the typeId checking logic will need changed every time a new entity type is introduced or changed.
Aucun commentaire:
Enregistrer un commentaire