Top "Factory-pattern" questions

This tag is sometimes used to refer to the Factory Method pattern ([factory-method]) and sometimes used to refer to the Abstract Factory pattern ([abstract-factory]). Please use either of those tags instead of this one.

instance factory methods Vs Static factory methods

Can't all factory methods be static ? Does something that produces a product need state ? When is it appropriate to go …

java factory-pattern
How to inject different services at runtime based on a property with Spring without XML

I am using Spring Boot for Java standalone application. I have a bean which makes use of a service. I …

java xml spring spring-boot factory-pattern
C# Generic Interface and Factory Pattern

I am trying to create a Generic interface where the parameter type of one of the methods is defined by …

c# generics factory-pattern
"Downcasting" unique_ptr<Base> to unique_ptr<Derived>

I have a series of factories that return unique_ptr<Base>. Under the hood, though, they are providing …

c++ c++11 smart-pointers factory-pattern unique-ptr
How to avoid 'instanceof' when implementing factory design pattern?

I am attempting to implement my first Factory Design Pattern, and I'm not sure how to avoid using instanceof when …

java design-patterns factory factory-pattern instanceof
Factory Design Pattern - Why Interface necessary?

I started looking at different design patterns, and now I am focussing on the Factory Design Pattern. I looked at …

c# design-patterns factory factory-pattern
How to correctly make a thread safe Singleton Factory in Java?

This is the first time I am writing a Factory class. Below is my Factory class, I am not sure …

java singleton factory-pattern
C++ Abstract Factory using templates

I'm trying to create an abstract factory template for multiple abstract factories in C++ and came up with this. #define _…

c++ templates factory-pattern
Using a Strategy and Factory Pattern with Dependency Injection

I am working on a side project to better understand Inversion of Control and Dependency Injection and different design patterns. …

c# design-patterns dependency-injection factory-pattern strategy-pattern
Spring dynamic injection, factory-like pattern

A continuation from Dependency injection, delayed injection praxis. I have the Main class: package test; import org.springframework.beans.factory.…

java spring dependency-injection factory factory-pattern