Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:48:21+00:00 2026-06-07T10:48:21+00:00

I would like to know whether it is possible to use an abstract factory

  • 0

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 {}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:48:24+00:00Added an answer on June 7, 2026 at 10:48 am

    Yes, there is no harm in combining more then one design pattern to get a problem fixed. from your design, I can see the following problems:

    The interface PizzaStore should not have all those creational methods as it does not really make sense (you are forcing all pizza stores to implement all those methods and what if a pizza store makes only veggie pizza?). A Strategy pattern says your have to have one method or abstract algorithm implemented in many different ways. This will give your the flexibility to switch algorithms and strategies at runtime.

    The ´PizzaStore´ should rather look like this:

    interface PizzaStore 
    {
        Pizza CreatePizza();
    }
    

    All PizzaStore implementations should then implement a CreatePizza method that will return a Pizza which should be an abstract class or an interface. Implementations/extensions of the Pizza should then be: PizzaCheese, PizzaVeggie, PizzaClam, PizzaPepperoni

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know whether it is possible to use a SELECT statement
I would like to know whether is it possible to use my HTC wildfire
I would like to know whether this is actually possible in Android? When Android
I would like to do the following. I don't know whether it's possible to
I would like to know whether it is possible to write code that would
I would like to know whether I can use DL Query in Protege programatically.
I would like to know whether it is possible to force LWP::UserAgent to accept
Accuracy Vs. Precision What I would like to know is whether I should use
I would like to know whether it is possible and good practice to report
i would like to know whether the following query is optimized? select SUM(payments.paid_amt) as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.