1,473 questions
-1 votes
3 answers
161 views
How can I make the factory class static in factory design pattern?
I was reading an e-book explaining design patterns, and after explaining the factory design pattern, it suggests some improvements. One of them was to make the factory static. Make the factory (or a ...
3 votes
2 answers
242 views
How to write an abstraction in Rust with multiple implementations
In my application I want to have an EventPersister trait that defines an abstraction of persisting events, then have various implementations that, for example, persist events in memory, in the file ...
0 votes
0 answers
44 views
Using Factory Pattern yields No qualifying bean for service interface injected into springboot controller
I am facing an issue with my spring-boot application. The API is using the factory design pattern along with JpaRepository. The API manages creation of "Route" which is "Road" in ...
0 votes
0 answers
102 views
How to ensure initialization of static variables without explicitly including the header file
Considering the following example: A class named ObjectFactory is defined to manage the creation of several classes. These managed classes should be registered with the factory so that we can create ...
2 votes
1 answer
184 views
The way to filter objects by type in the factory
I have the factory that contains a map with the names of objects as key and pointer to function as value template<class T> static T* makeObj() { return new T(); } using createFunction = std:...
0 votes
2 answers
706 views
Understanding Factory Design Pattern in Python
The Python version of the Factory pattern in Refactoring Guru is: from __future__ import annotations from abc import ABC, abstractmethod class Creator(ABC): @abstractmethod def factory_method(...
0 votes
2 answers
339 views
How to Use Factory Pattern With Dependency Injection and input parameters?
I'm trying to understand how to create an instance of a service (for example, ITransport) with some input config at runtime using the Factory Pattern and Dependency Injection (Microsoft.Extensions....
2 votes
1 answer
93 views
C++ factory of a container type without defining the container element type
Based on this topic, I wonder if it would be possible to have a factory class that would provide a container type, without defining the type of element of the container. Something like: template <...
0 votes
0 answers
49 views
Factory Reverse design pattern discussion
I used to use factory method as a creational design pattern, but now I got stucked in the situation which is reversing the problem. The normal behavior to create the factory pattern. I am facing the ...
0 votes
0 answers
123 views
How to merge two view content using factory design pattern in swift
I am following factory design pattern . From the view model state response I am rendering the view. For movie details view I am rendering MovieDetailsDisplayViewController. view content. Here is view ...
0 votes
1 answer
107 views
Why do we use factory class to instantiate interface
I'm currently reading book pro spring 6. I am a bit confused on one example from book Here is the main class: public class HelloWorldDecoupledWithFactory { public static void main(String... args)...
0 votes
2 answers
288 views
Does factory design pattern violate Dependency Inversion Principle of solid principle in C#? [duplicate]
By definition, dependency injection promotes loosely coupled, maintainable, and testable code, and using interface and constructor injection we can get the object of the class implementing the ...
0 votes
1 answer
49 views
Factory Method: Why not one CreateMethod in Factory for each Type?
So I was reading along Design Patterns book to look up some details on the Factory Pattern. I was reading about two main variants of implementation: Using the abstract Factory and ConcreteFactories ...
2 votes
2 answers
3k views
How to resolve services in factory class using dependency injection? | C#
I have six implementations for the same interface registered on my DI container, like so: services.AddScoped<IProductService, ProductService1>(); services.AddScoped<IProductService, ...
0 votes
1 answer
116 views
Mod-wsgi calls flask factory function twice
I am trying to build a flask app and using mod_wsgi server for hosting. I use a factory function to create the flask app but I observe that mod-wsgi calls the factory function twice within the same ...