Skip to main content

Questions tagged [factory-method]

Use this tag for code reviews of, or involving methods that create a new instance of a given type, often with parameters that determine how the instance gets created.

Filter by
Sorted by
Tagged with
5 votes
1 answer
386 views

I've been transitioning from type-safe programming languages like Dart and Java to Python, and I'm trying to enforce Domain-Driven Design (DDD) principles in a language that naturally leans towards ...
koussay issaoui's user avatar
3 votes
1 answer
113 views

The Context I have a toy ECS architecture where I want to serialize and deserialize the whole app state for hot-reloading DLLs. I don't want the user to have to register all components at the ...
Gabriel Lanzer's user avatar
2 votes
1 answer
440 views

I have this code for a factory design pattern that will take into account any number of arguments in the constructor. Through a static boolean in the class a ...
user avatar
2 votes
1 answer
83 views

My class is a factory-method that allows to instantiate it only when the parameter $type (string) is "regular or premium" and when parameter $months (integer) is lower than 6. If $months is ...
Ricardo Castañeda's user avatar
2 votes
1 answer
96 views

Consider the following code: ...
prestokeys's user avatar
  • 1,401
1 vote
1 answer
151 views

I asked the same question Web scraper for e-commerce sites yesterday and I'm now posting the revised code here. I'm building web scraper application which takes name, code and price from few sites. I ...
Xyloto's user avatar
  • 123
0 votes
1 answer
234 views

I'm building web scraper application which takes name, code and price from few sites. I thought factory pattern would fit in my application. I would like to someone review my code and tell if I ...
Xyloto's user avatar
  • 123
4 votes
2 answers
206 views

I'm learning Factory pattern and I've implemented this simple example of an abstract factory. I've followed this video a little bit while writing this small example. Is there anything anti-pattern or ...
Hammas's user avatar
  • 151
2 votes
1 answer
385 views

This package is on pub dev here It's on Github here ...
Christian Findlay's user avatar
1 vote
1 answer
91 views

Problem: My application is built upon clean architecture. I want to create a new instance of a class in my lower layer, but the class itself resides in an upper layer. The upper layer can depend on ...
Damian Nizio's user avatar
1 vote
3 answers
219 views

I implemented the Abstract Factory design pattern as follows. Concrete Implementation ...
Turtle's user avatar
  • 165
21 votes
2 answers
5k views

Inspired by a question on StackOverflow I decided to code a GUI that is simple, efficent and can be used in other projects as well. I wanted to share this code since it probably is usefull to other ...
Thingamabobs's user avatar
14 votes
4 answers
2k views

I have tried my hand with implementing simple quadrature formulas in C++. Definite integral: $$\int_a^b f(x) dx$$ Domain of integration \$[a, b]\$ divided into \$n\$ intervals of equal length \$h = (b ...
Giogre's user avatar
  • 515
0 votes
1 answer
466 views

I have used the factory pattern for one of my projects. I want to know if this is a good design or if my code can be improved to make it as fast as possible. I am not an expert in C#. This is what I ...
Valour's user avatar
  • 103
2 votes
1 answer
3k views

I wanted to have a factory-method, but without the if statements that are often seen in examples of this pattern. So I came up with this, and would like to know: is ...
Alex's user avatar
  • 121
2 votes
3 answers
417 views

File: InfoFactory.h contains four classes. CaffienatedBeverage is an Abstract class with one pure virtual function Name. It ...
Stew's user avatar
  • 125
3 votes
1 answer
171 views

I've always struggled to create and sustainable, organizated, clean code. I tried to use a Factory method and it's working better now that I created another class. I know I should write documentation,...
hamon's user avatar
  • 55
5 votes
1 answer
2k views

I'm trying to write a factory class that essentially provides a user-friendly frontend to creating objects of different kinds depending on keywords. So the user will just have to import this module, ...
Seamus's user avatar
  • 151
3 votes
1 answer
148 views

I Have this class want to practice how to write a factory method pattern and I can change the logPlace by set the app.config, and I try to improve the performance ...
hung's user avatar
  • 31
0 votes
1 answer
317 views

I'm implementing a simple data reader to get image sequences from either a pre-recorded video file (In my case ROS bag file), or a camera device (In my case Intel Realsense). Basically I intend for ...
zhouch's user avatar
  • 3
10 votes
0 answers
2k views

About This is a follow-up of a previous question Private VBA Class Initializer called from Factory. I've decided to create a new question instead of answering my old question because I would like the ...
Cristian Buse's user avatar
8 votes
1 answer
630 views

I've been playing with COM lately and while getting to understand the mechanism of how class methods/properties are called an idea came to mind: what if we can have a global instance of a class that ...
Cristian Buse's user avatar
4 votes
1 answer
2k views

I am a little bit confused on Factory Method with multiple parameters in which all parameters can change from GUI by user as seen below picture. For each combobox item I have an interface and ...
YrnHkn's user avatar
  • 43
2 votes
1 answer
260 views

I have a .NET application with a .config file that has content like this: ...
Michael Brandon Morris's user avatar
2 votes
0 answers
283 views

Edit: I added another configuration vector to CardView, a size attribute, which may be .small or ...
Richard Robinson's user avatar
0 votes
1 answer
134 views

Here are my class library code which create credit card. ...
Steve Ngai's user avatar
4 votes
1 answer
825 views

I have a couple questions about this program Should I implement runnable instead of using thread class? I like the idea of the consumer and producer being thread objects, it seems simpler to me, but ...
James's user avatar
  • 43
1 vote
1 answer
94 views

This is my first question on this website and I hope it goes well. I have created a Kotlin factory pattern and I am using it very frequently. the code I use it consists of functions inside a class. ...
Dimitrios Filippou's user avatar
10 votes
3 answers
6k views

Design A template class that will create a concrete instance of an interface class when given the name (as a string) of the concrete class. This design is often seen in code, so the purpose of this ...
Blue7's user avatar
  • 373
0 votes
1 answer
68 views

I am trying to figure out how Factory pattern works. I implemented it with TypeScript in this github repo: https://github.com/emilecollin/factory_pattern Basically this is emulating spaceships gaming ...
user avatar
3 votes
1 answer
226 views

I am working on an e-commerce website. What I need to do is to save an advertisement. The ad has some properties and some photos... properties should be save to DB and photos should be saved to file ...
Hooman Bahreini's user avatar
4 votes
1 answer
434 views

I want to create a factory to return all Source instances that match given entry parameters- that is, I want to iterate through some Collection of objects and for each entry check boolean method. I ...
Khayn's user avatar
  • 43
4 votes
0 answers
277 views

In this SO post Dynamically choose class from string Alexander Platonov creates a Function on the fly and then uses Application.Run() to instantiate an Object by ...
TinMan's user avatar
  • 4,328
1 vote
1 answer
2k views

I have a custom model binder which takes user input in HTML format, sanitize the HTML input by removing any script or XSS threat and returns the sanitized HTML string: ...
Hooman Bahreini's user avatar
1 vote
1 answer
70 views

Consider this code: ...
Dennis's user avatar
  • 281
7 votes
3 answers
7k views

I have written code for making a Chess Validator, which will validate the moves of a chess game. There is a Main class which is taking the input from the user, about the move. Problem Description ...
Yashi Srivastava's user avatar
0 votes
1 answer
169 views

I, also, need to know whether this is a valid implementation of the factory pattern. The amount of effort which goes into configuring DriverFactory to simply get a ...
Thufir's user avatar
  • 369
3 votes
1 answer
210 views

I am building an e-commerce website. I have an application layer service called SearchService. SearchService receives a search ...
Hooman Bahreini's user avatar
0 votes
2 answers
2k views

I am implementing the factory method approach. My intention is to know if my approach is correct for factory method. Any modifications to be done to align with the approach? First I am creating an ...
krishna_v's user avatar
  • 167
4 votes
1 answer
2k views

I recently appeared for interview for code-pairing round and I was asked following question: Electricity Billing System for home. The corresponding power usage of home appliances (Fan, AC, Fridge, ...
Ankita's user avatar
  • 41
2 votes
2 answers
540 views

I currently had a colleague reviewing my code and he had a comment on a factory class I created. It's very simple: ...
Giel Berkers's user avatar
1 vote
2 answers
277 views

I have created a Synchronizer, the purpose of which is to read data from an XML source file and store the result in a DB. I have different source types, for example Student.XML, School.XML, etc. ...
Hooman Bahreini's user avatar
1 vote
2 answers
3k views

I know questions with this text has been asked and already answered, but my question is mainly limited to only one method of this flow and where it should be. I have an assembly for Shape's area ...
Amit's user avatar
  • 195
4 votes
0 answers
99 views

I want to make factories that can chained together to create a pile of layers. One of the advantage of chained factories is that later factories can pass specifications to earlier factories. For ...
R zu's user avatar
  • 287
2 votes
1 answer
217 views

I am currently attempting to understand the fundamentals of factory methods in Java and I found a lot of exampels where a pattern like this has been used. I got some exercises about sorting algorithms ...
L.Spillner's user avatar
8 votes
4 answers
2k views

I'm working on a network application that implements a custom protocol. I want to easily extend the application support over the protocol as it changes. Also, as the application extends, I might need ...
Cosain Melic's user avatar
2 votes
0 answers
361 views

Demo for a SoundCloud player in WebView for specific song or artist stream as a workaround because SoundCloud is not accepting API key request anymore. SoundCloudWebView: ...
Vhalad's user avatar
  • 91
6 votes
3 answers
2k views

I have a HTTP client factory that creates a separate HTTP proxy instance for each of my services - which are in the cloud. The factory creates each instance on the basis of an interface which the ...
Alternatex's user avatar
1 vote
2 answers
126 views

Background Last year, while I was still entering the beginning of Immutability and Pure functions and whatnot I created a library for the community called ...
Flame_Phoenix's user avatar
5 votes
2 answers
225 views

I am creating a fluent interface to build user interfaces in the Unity game engine. As a subcomponent of this library, I have a set of objects called Components (e.g. Panel, Button, etc) that I want ...
Nick Udell's user avatar
  • 5,247