Questions tagged [factory]

"Factory" is a general term for object-oriented programming patterns which create objects. Instead of this tag, please use tags for the specific Gang of Four patterns [factory-method] or [abstract-factory] when appropriate.

Filter by
Sorted by
Tagged with
1 vote
1 answer
90 views

Java Factory pattern

I have module A and module B each one have some specific services and i have a module C that don't have any dependencies to A and B so what i want is to call services from modules A and B and I want ...
Ramzi Mrabet's user avatar
0 votes
2 answers
73 views

Flask, Marshmallow and Sqlalchemy factory problems

I am building a Flask RESTful application and I'm trying to build it with a factory design pattern but I think I'm missing something. Here are my set up files app.py: ` from src import create_app, ...
Dan Gordon's user avatar
0 votes
1 answer
24 views

Dynamic values for objects built by factories

I have a factory for building objects when testing. Below is the code. As you can see, I have one private object, which is the object I will use to build the object the factory returns; I also have ...
Bernardo Benini Fantin's user avatar
0 votes
1 answer
43 views

Azure copy activity

Azure copy activity is taking so much time and want to reduce it. Basically I have around 200 folders and every day data is getting updated with the latest date folder. And I have to copy only few ...
Srinath Sona's user avatar
0 votes
0 answers
34 views

python django factory set random locale and then create model based on this locale

I would like to create test models of people of different nationalities. During creation, factory would randomly select nationality from a list of "locale" attributes. It would then ...
Jacek's user avatar
  • 51
-1 votes
1 answer
143 views

Target class [config] does not exist error in laravel for testing

So I am trying to use testing with factories in laravel And I've been getting this error for a long time it's annoying I am trying to make a test with faker by checking if it creates and inserts data ...
Intr0vert's user avatar
0 votes
0 answers
30 views

How to type hint arguments of factory method, where the managed instances are from generic class with additional constructor args

Consider the following case where we have a Manager which manages instances of certain classes. These classes must be a subclass of a given class but can be user-defined (i.e. are a generic). Since ...
Andreas H.'s user avatar
  • 5,652
0 votes
0 answers
32 views

factory with additional optional parameterrs

I have the following factory class, which takes as a parameter a value $type based on which it creates a different class, and some additional optional parameters, which are passed only to the class ...
Orestis uRic's user avatar
0 votes
0 answers
24 views

Why i get this exception( UnsatisfiedDependencyException) [duplicate]

Exception Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2023-09-29T20:44:57.421+04:00 ERROR 28232 --- [ main] o....
Elshan Nuri's user avatar
3 votes
1 answer
69 views

Factory pattern where abstract class has templating?

This is a problem where I understand why the issue is occurring, but I don't know how to change my design in order to fix it. It's my first time trying to use templates in C++, and I want to make a ...
tomysshadow's user avatar
1 vote
2 answers
65 views

Instantiate different objects based on state of some variable (without factory method)

I am trying to instantiate a different type of object, depending on the state of some variable. I think the official way to do this is with something called a factory method; but that is beyond my ...
1Teaches2Learn's user avatar
0 votes
0 answers
7 views

C++ Cannot template abstract factory singleton without undefined error

I'm trying to create an AbstractFactory class that is templated on the base class. The abstract factory is a singleton but when I declare it for a baseclass I get an undefined error. This system works ...
Will Denny's user avatar
0 votes
1 answer
39 views

Laravel - Why is my test setUp() function failing?

I've constructed a test in which I'm using this setUp() function public function setUp(): void { parent::setUp(); Carbon::setTestNow('2001-01-01'); (new UserFactory()) ...
nuwe's user avatar
  • 107
-1 votes
1 answer
87 views

Laravel 10 - Running a factory - ParseErrorException.php

I have this factory I am trying to run through Tinker: <?php namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; use App\Models\User; /**...
Kami Barut's user avatar
0 votes
0 answers
34 views

Laravel factory startup error Array to string conversion

In my Laravel project I am using the Astrotomic Laravel Translatable package. I want to create a factory to generate random data.My factory code public function definition(): array { $locales = ['...
Денис Линник's user avatar
1 vote
1 answer
35 views

how to access relations of laravel factory from inside another factory

I have a model called Company, and Fields are added to it via an observer after it is created: protected static function booted(): void { static::created(function (Company $company) { ...
jdion84's user avatar
  • 39
0 votes
1 answer
48 views

Generics and Factory pattern

I'm trying to implement a base factory class that has a list of different instances with different IDs in Unity. It will have a list of prefabs I mean. I'm going to implement lots of different ...
Roduraz's user avatar
  • 25
0 votes
2 answers
24 views

Getting ImportError after setting up Flask application factory

I am making a basic blog website with Flask. I have tried to stick to the best recommended practice as mentioned in official documentation. I want to understand why after adding application factory ...
dartHTh0t's user avatar
1 vote
0 answers
46 views

Add both listeners and text formatting to TableRow [closed]

I have a class JobTable which extends TableView. The TableView has a drag and drop feature from the following code: setRowFactory(tv -> { TableRow<Job> row = new TableRow<>(); ...
cworner1's user avatar
  • 461
3 votes
3 answers
500 views

How to hide constructor on a Java record that offers a public static factory method?

I have this simple record in Java: public record DatePair( LocalDate start , LocalDate end , long days ) {} I want all three properties (start, end, & days) to be available publicly for reading, ...
Basil Bourque's user avatar
0 votes
0 answers
47 views

Abstracting away this Factory pattern

I'm working on a project that has a number of classes that wrap various AWS services. These wrapper classes all share a common factory pattern (mostly centered around assuming a role) and I'd like to ...
Aurelia Peters's user avatar
0 votes
2 answers
121 views

How to use random id of same model in laravel factories?

I am trying to build a simple page hierarchy for a website in Laravel and want to create a factory for my Page model. A column in Page is 'parent_id' which I want to populate with the id of another ...
Typhoon101's user avatar
  • 2,073
1 vote
1 answer
57 views

Why does a derived class from CRTP template not initialise the static variables?

So I'm trying to create a factory based on CRTP. For simplicity, I will just include whatever is relevant here. I got two questions which might be irrelevant to each other, but was stuck trying to ...
ashura's user avatar
  • 13
1 vote
1 answer
44 views

Generic factory typings

There is simple factory and I don't understand why typescript produces error at main function createFeature. How would be proper to describe types? interface Feature { id: string; kind: string;...
Vitaliy Leonov's user avatar
0 votes
1 answer
55 views

VBA: Circular reference in factory class

In a Excel VBA project, I have several classes and interfaces. Each sheet in the excel workbook corresponds to an instance of a VBA class "clsPmModule". The instances are created by ...
user14181536's user avatar
1 vote
1 answer
19 views

Explain implementation of function call operator in boost value_factory

I am trying to understand the boost implementation of factory design pattern. Boost provides two types of factory one for pointer types and other for value semantics. I am able to understand a little ...
Daemon's user avatar
  • 1,595
0 votes
1 answer
84 views

How to pass constructor args using Microsofts DI container?

Given the code example at the end of this question, how would you configure a Microsoft DI container to resolve the types? For example, I would like to be able to have something like : var services = ...
Vastar's user avatar
  • 63
-1 votes
2 answers
124 views

DI : Resolve dynamic type whilst also passing in constructor args

I have a Document class that has a list of Objects. To create and add an Object, you pass in a numeric object type id to Document.CreateObject(). Then depending on the type id, it will create the ...
Vastar's user avatar
  • 63
0 votes
1 answer
257 views

Using the Angular inject function with a APP_INITIALIZER

With Ivy, Angular introduced the nice inject function. According to the documentation the function can be used "from a provider's factory" accompanied with the following example: providers: [...
Mikkel R. Lund's user avatar
0 votes
0 answers
64 views

Solidity: Using inherited constructors with a proxy factory

I am attempting to use Chainlink VRF along with OpenZeppelin's upgradable contracts to generate a random number. In order to use VRF, I must inherit the constructor from VRFV2WrapperConsumerBase. ...
root's user avatar
  • 1
0 votes
4 answers
80 views

How can I prevent callers from creating a C#/.Net 7 class object *EXCEPT* by calling a static "CreateInstance()" method?

I have an abstract base class "UserFeedback", and a couple of subclasses "A" and "B". UserFeedback has a static "CreateInstance()" method. I'd like to PREVENT ...
paulsm4's user avatar
  • 119k
0 votes
2 answers
525 views

Laravel use randomly created factory for relation

I'm trying to seed random belongsTo relationships for a Post, but they are all just being created with the same User and Community. Code: $users = \App\Models\User::factory(100) -&...
jdion84's user avatar
  • 39
0 votes
0 answers
27 views

Can't solve NullSafety to test a fromJson Factory

I'm giving a try on Flutter but having a hard time trying to follow TDD process giving Null Safety complexity. A made a simple test (below) for instantiating a Model but I keep getting like Null check ...
Pedro Brasil's user avatar
0 votes
1 answer
88 views

Azure Data Factory pipeline to process each line in CSV separately and conditionally copy data into Dynamics CRM

I need some help with the following issue. I have a bunch of CSV files which, in my pipeline, I read from Azure BLOB storage. Now each CSV file contains a list of records, and all CSV files use the ...
Para Jaco's user avatar
  • 211
0 votes
2 answers
75 views

Factory class in Python with a mapping dictionary returns TypeError

I made something like this dummy class: class CreateCaseFactory: @classmethod def create(cls, user_id: uuid.UUID, type_: str) -> str: creator = cls.CASE_TO_METHOD_MAP.get(type_) ...
KZiovas's user avatar
  • 3,825
0 votes
0 answers
40 views

Cannot be provided without an @provides-annotated method for migration from dagger to hilt

Please help me with such error. I'm trying to use dagger and hilt in one project. DataSource eas using a dagger, but I want to implement hilt for use. And hilt shows an error cannot be provided ...
Slava's user avatar
  • 473
0 votes
1 answer
87 views

Is this design introducing Circular Dependency?

Supposed I have two types of customers - Regular and VIP. I would like to give discounts to them based on CustomerType and their attributes. I have following design in my mind: class Customer { ...
Pandey's user avatar
  • 91
0 votes
1 answer
98 views

Anylogic Error : root.arrival: Trying to schedule an event in the past. Negative timeout: NaN

I have an anylogic model that connects to an MQTT network. When it receives some messages (sometimes no messages at all) it throws this error and stops the model. root.arrival: Trying to schedule an ...
M MO's user avatar
  • 323
-1 votes
1 answer
155 views

Laravel 8 - User factory error - `Field 'username' doesn't have a default value`

I am working on test coverage for this project and now I need to create a User model factory. I created this factory using the artisan command: php artisan make:factory UserFactory After call User::...
Max Slyusarchuk's user avatar
1 vote
2 answers
808 views

Is it possible to create mock data using pydantic-factories in such a way that attributes adhere to pydantic validator requirements?

I'm trying to create some mock data, where one of my classes (for which I specified a Pydantic dataclass by inheriting from Pydantic.BaseModel) has date attributes. I want to make sure that the ...
Sam's user avatar
  • 305
0 votes
1 answer
41 views

How to avoid "as any" in nested TypeScript type predicate functions?

I'm working on a factory to create class instances from typed objects in TypeScript that I am receiving through my server API. In order to know what instance to create I'm using type predicate ...
BooleanAssange's user avatar
1 vote
1 answer
50 views

Fetch http in Flutter - factory constructor needs update after every currency change

I am new to flutter and working with http requests for the first time. I have no problem making the code work in the first instance since factory constructor fetches bitcoin price in USD: json['RAW']['...
scarmose's user avatar
1 vote
1 answer
115 views

How to use Factory Class and attributes in Delphi Spring4D

How to use attributes correctly to create different implementations for the IDog interface in the IDogFactory interface? Is it possible to create different implementations for one interface using ...
Tomasz Bojara's user avatar
2 votes
1 answer
58 views

Factory function of different types in rust

I'm trying to write a function in rust that builds different types of objects (all implementations of a same trait) but I'm running into troubles, not understanding if I'm trying to do something ...
Pyper's user avatar
  • 33
0 votes
1 answer
203 views

Azure Data Factory Snowflake ODDBC connection - Cannot create pipeline to run script

I'm trying to run a script on Snowflake from Azure Data Factory. This is so we can use elevated rights to run these script and we can use the scheduling capabilities of ADF to run it on weekly basis. ...
mac's user avatar
  • 307
-3 votes
1 answer
150 views

How can I have macros as arguments inside macros?

I have multiple macros at beginning of each GameObject child class header. This is intended, as the client might add any number of classes inheriting from GameObject, with any engine macro arguments. ...
GitButtCoder's user avatar
0 votes
2 answers
62 views

How to have Factory registry macros in the beginning of header files?

Currently, the Factory registry macro im using is at the bottom of the header file: #pragma once #include "GameObject.h" class Foo : public GameObject { //... }; ENGINE_SPAWNABLE(Foo); ...
user avatar
1 vote
1 answer
184 views

What's the difference between a factory constructor and a named constructor or method? [duplicate]

I can't understand the real purpose of factory constructors. I have this code that contains a method and a factory constructor: User fromJJson(Map<String, dynamic> json) { final user = ...
Mikelenjilo's user avatar
0 votes
1 answer
39 views

Java - Is it possible to create a Comparator factory with an argument which changes the compare method?

I have a class VectorClock which extends ArrayList<Integer>. I want to sort the elements, but these only have a partial order. A vector clock is greater than another only if all the elements are ...
Javier de Muller Santa-María's user avatar
0 votes
0 answers
23 views

Factory System with 2 difrent Values

I have created a Factory System. It works fin, but i have a Problem with the VAT Calculation I take a Value from the Database and it is stored in a array. So, if i take out the Data with a For-Loop ...
Patrick Brockmann's user avatar

1
2 3 4 5
64