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 ...
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 ...
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
335
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....
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
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
1
answer
48
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 ...
0
votes
1
answer
110
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 ...
0
votes
1
answer
337
views
How can the Factory design pattern be employed in designing a system similar to Amazon shopping? [closed]
I have been reading system design of an amazon shopping website like system on educative, it is mentioned in the solution that
In the Amazon online shopping system, we can use the Factory design ...
0
votes
1
answer
144
views
Right pattern for creating concrete classes of an interface [closed]
I have an interface which is implemented by different classes. I want to make the implementation classes package private so that clients only use the interface, but of course they somehow need to ...
0
votes
0
answers
208
views
Is it possible to implement the factory pattern if the derived classes can make recursive calls to create other classes?
So I'm currently working on a GUI in PyQt5 and I'm creating a window based off of a yaml settings file that contains information about what widgets should be contained within the window and some of ...
0
votes
3
answers
256
views
How to properly implement derived classes with their own functions in a Factory Pattern?
I face a problem with derived classes having their own functions when using Factory Pattern. Please share how you design OOP in this case.
Assume I have a general class B, and many derived classes, ...
0
votes
2
answers
110
views
factory method for multiple constructors in the same class
I have this code which is an adaptation from How to pass arguments to factory elements constructors? to work with smart pointers.
#include <unordered_map>
#include <string>
#include <...
1
vote
1
answer
250
views
How to dynamically choose what concrete class to use in dependency injection
I usually write something like this for my DI:
var serviceProvider = new ServiceCollection()
.AddSingleton<ISomething, Something>()
.AddSingleton<IOutputMaker, ...
0
votes
1
answer
48
views
Python import Error "Can not find module src"
I am facing this error "Can not find module src" while executing command pytest. My create_app function is inside src/ __init__.py
The structure of project is
project
src
...
0
votes
1
answer
124
views
reduce code duplication - factory design pattern
I have created a small chess game and implemented a factory class to produce game pieces. However, I realized that my implementation is not ideal, as every game piece is responsible for registering ...
0
votes
1
answer
139
views
Identify the best architecture for sending different types email in ASP.NET Core
I have defined an interface IEmailManager as having send method. The email controller is using its concrete type EmailManager as a constructor dependency that sends the email.
public interface ...
1
vote
2
answers
89
views
How to set type in Factory pattern in which exists multiple interfaces
There are like these types
interface A {
id: number
name: string
patternA: patternA[]
}
interface B {
id: number
name: string
patternB: patternB[]
}
interface C {
id: number
name: ...
4
votes
1
answer
14k
views
Typescript/Javascript Circular dependency: Class extends value undefined is not a constructor or null
Question
Hello,
the following code example throws the error:
TypeError: Super constructor null of SecondChild is not a constructor
at new SecondChild (<anonymous>:8:19)
at <anonymous&...
0
votes
1
answer
69
views
Can function with same signature but different implementation be triggered simultaneously in python?
class A(Factory):
def func1(self, param1):
print(param1 + " class A")
def func_A(self):
print("Func A")
class B(Factory):
def func1(self, param1):
print(param1 + ...
1
vote
1
answer
63
views
Is there a design-pattern that addresses creation of the same product in multiple different ways (requiring pipeline-like pre-creation steps)
I am currently working on a machine learning project and would like my Python program to be able to process/convert measurement data from various measurement data formats into a PyTorch compatible ...
0
votes
0
answers
68
views
What do I do if I have multiple components?
I just started using Autofac. How do I register multiple components? I see this in the QuickStart guide:
private static IContainer Container { get; set; }
.
.
.
var builder = new ContainerBuilder();
...
0
votes
1
answer
109
views
Understanding the code in an Abstract factory pattern
I am trying to learn design patterns in C# and my friend has written me some code for an Abstract factory pattern (I think).
from what I am seeing the code creates a factory(Fa),
this factory(Fa) then ...
0
votes
1
answer
120
views
Separated (decoupled) API (a creator class) for the classes of a library with constructots having different signature
I have a library for 3D geometry. The library has classes like Point, Vector, Axis, Plane etc. The library has an interface and implementation hierarchy but simply all classes inherits from ...
1
vote
1
answer
157
views
Why is my linked list object in JavaScript not updating when I try to add a node to the beginning of the list?
I'm trying to create a linked list using a factory function. When I run the method append on the list console.log displays the correct value. The prepend method on the other hand doesn't seem to be ...