I would like to know whether it is possible to use an abstract factory as a strategy, e.g. nesting the two patterns and call the factory class a strategy as well.
I provided an example to illustrate my question. The class ShoppingMall
would be the context class, while PizzaStore
would be the abstract factory in question I would consider to be a strategy in this case as well.
// interface of context class, mostly a wrapper
// uses 3 different strategies
interface ShoppingMall
{
PizzaStore GetPizzaStore();
ParkingLot GetParkingLot();
Adverts GetAdverts();
void CustomerArrives();
}
// abstract factory & strategy interface?
interface PizzaStore
{
Pizza CreatePizzaCheese();
Pizza CreatePizzaVeggie();
Pizza CreatePizzaClam();
Pizza CreatePizzaPepperoni();
}
// strategy interface
interface ParkingLot
{
void Pay();
}
// strategy interface
interface Adverts
{
void CreateSpam();
}
class PizzaStoreChicago implements PizzaStore {}
class PizzaStoreNY implements PizzaStore {}
class PizzaStoreObjectVille implements PizzaStore {}
class ParkingLotBig implements ParkingLot {}
class ParkingLotSmall implements ParkingLot {}
class ParkingLotCheap implements ParkingLot {}
class AdvertsAnnoying implements Adverts {}
class AdvertsBoring implements Adverts {}
class AdvertsStupid implements Adverts {}
class ShoppingMallObjectVille implements ShoppingMall {}
class ShoppingMallJavaRanch implements ShoppingMall {}
class ShoppingMallAverage implements ShoppingMall {}
class ShoppingMallOther implements ShoppingMall {}