problem about abstract-factory-Collection of common programming errors


  • Christian Metzler
    dependency-injection abstract-factory
    Given the following class hierarchyClassA needs ClassB ClassB needs ClassCwe get a dependency graph like this:ClassA –> ClassB –> ClassCso if we use DI we inject ClassC into ClassB and ClassB into ClassA.But now let’s say ClassC is a runtime dependency (for example some kind of strategy). The proposed way to inject a runtime dependency is to introduce an abstract factory like a ClassCFactoryNow we can inject ClassCFactory into ClassB and get the following graphClassA –> ClassB –>

  • bibs
    java dynamic-typing abstract-factory
    I am using an abstract factory to return instances of concrete subclasses.I would like to instantiate the subclasses at runtime given a String of the concrete class name. I also need to pass a parameter to the constructors. The class structure is as follows:abstract class Parent {private static HashMap<String, Child> instances = new HashMap<String,Child>()private Object constructorParameter; public static Child factory(String childName, Object constructorParam){if(instances.keyExist

  • Aggelos Biboudis
    c++ covariance abstract-factory
    Having in mind the abstract factory pattern, imagine that you have a class hierarchy where concrete factories override a createButton*s* virtual method, needing to return a wider array of buttons. What could be an elegant workaround to resolve this, as C++ supports only covariant return types? dynamic_cast?A modified version of GoF’s example to fit my requirement:class Button { public:virtual void paint() = 0;virtual ~Button(){} };class WinButton: public Button { public:void paint() {cout <&l

  • Don
    java design-patterns abstract-factory
    I’ve implemented an abstract factory like thispublic abstract class AbstractFactory {private static final Map FACTORIES = new HashMap(); AbstractFactory(FactoryType type) {FACTORIES.put(type, this);} public abstract A getA();public abstract B getB();public static AbstractCatalogFactory getFactory(FactoryType type) {return (AbstractCatalogFactory) FACTORIES.get(type);} }A concrete factory must call this abstract factories constructor, causing each concrete implementation to be registered in

Web site is in building