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.
3
votes
1answer
75 views
Generating Settings Objects from Database via Factory Class
In an ASP.NET MVC application (C#) have a factory-like class that generates settings objects of ISettingType for my application. However, some settings are very ...
3
votes
4answers
127 views
Factory Method Pattern - Base implementation to Add New Records
Most importantly which bothers me in the following implementation is the call in BranchAddManager, do I really need to call ...
4
votes
2answers
70 views
1
vote
1answer
61 views
Factory to create Finite Impulse Response filters in C++
I've recently begun a project in digital signal processing and am using C++ as the programming language. In this project, I have implemented several finite impulse response (FIR) filters. Many of ...
3
votes
2answers
101 views
Window Factory and Manager using MVVM pattern
I am fairly new to Factories and Dependency Injection in MVVM.
I've build my View(Window) factory with help from SO, and I would like to know if I had implemented everything properly(code works just ...
4
votes
2answers
81 views
Python REST API clients
I am working on a project right now, where we need to search different APIs, then clean & persists data to database and finally pushing to Elasticsearch.
The high level code looks like this:
<...
4
votes
2answers
89 views
Sequence generators not only for potatoes but also for apples and oranges
The last question about sequence generators Growing potatoes in delayed sequences was only about potatoes. I thougt why not make it work with apples and oranges too so I made it generic.
The base ...
1
vote
2answers
279 views
SQL Prepared Statement Factory
I have written a simple prepared statement factory in Java and would like some feedback on how "secure" it is. By "secure" I mean that I can pass any old garbage in as a string and it should not allow ...
5
votes
2answers
171 views
Simple factory pattern for cooking a pizza
I have developed a command line application which prompts the user to initially select an oven and then requests that they cook a pizza. The oven affects the pizzas cooking time. The pizzas ...
2
votes
1answer
69 views
Object publisher factory
I have an IPublisherFactory which publishes instances of, IPublishers.
I'm feeding it a bunch of overloaded methods from this gigantic class, that I'm basically using for organization of the ...
0
votes
2answers
142 views
Implementation of Factory Method pattern for XML and Excel documents
I started learning factory pattern, and also implemented factory method pattern.
My factory-method pattern classes are as follows:
There are two major parts, an interface "Document.java" and and ...
3
votes
0answers
113 views
Factory (pattern) of Commands (pattern) with additional dependency injection (dependency inversion pattern)
What would you improve at the following code, except:
The problems I'm already aware of, marked as TODO
Line width of at most 120 characters (I've run flake8 over ...
3
votes
0answers
66 views
2d game enemy entities factories, probably in need of refactoring
So I'm making a 2d shoot'em up game as a way of learning canvas, and larger-scale programming than what I'm accustomed to. I'm a purely front-end web dev, I can't say I'm very experienced in this.
...
1
vote
0answers
41 views
Extensible factory method for starting D3 charts
I'm working on refactoring some existing code to be a bit more extensible and am wanting to create a generic factory API for starting D3 charts.
Currently, my factory looks like this:
...
12
votes
3answers
1k views
Building car factory with custom features per car
I was once asked in an interview to build a factory that makes cars.
All cars has common features like price, rating and color and they have some features like fuel injection which can on specific car ...
3
votes
1answer
48 views
Factory to augment JS classes with validation methods
I have some validation classes. To keep things smooth, I create a single class that has those validation classes inside of it. That class will be a singleton, and gets injected into my other classes.
...
3
votes
1answer
102 views
Factory method that constructs objects that represents MySQL data types from query results
I'm writing a package that is designed to provide a convenient way to inspect the schema for a database. The goal is that I can use it for generator code to suit the schema. The complete code can be ...
11
votes
2answers
533 views
Beep-beep I'm a car factory
I have implemented to following generic factory in C++11 using smart pointers and I would like to get some feedback about it.
(Please note that I can't use C++14)
Due to company policies I have to ...
3
votes
1answer
90 views
Extending functionality of org.springframework.batch.item.file.transform.DefaultFieldSet
I would like to be able to set token values (defaultFieldSet.tokens) and names (defaultFieldSet.names) on ...
2
votes
0answers
71 views
Data structure of in-memory database [closed]
I am learning OOP, SOLID principles and design patterns. I have designed data structure of in-memory database in C#. Please provide suggestions to improve it better considering solid principles, OOP ...
1
vote
1answer
40 views
Factory that Creates Reusable Class Builders for a Racing App
In a project for fun/practice, I made a few builder classes that all started to feel the same, so I decided to generalize them by creating a factory that would automatically assign the similarities ...
6
votes
1answer
69 views
Extendable JavaScript module that converts between camelCase, PascalCase, and underscore_case
The basic idea is that by defining three functions--recognize, dissect, and combine--...
4
votes
2answers
391 views
Angular notification (alert) factory or directive
I am new to AngularJS and I thought of trying something simple: a notification factory that is useful for displaying actions alert messages like "Save successfully!" or "Validation errors: ...".
The ...
2
votes
2answers
54 views
Instantiating different kinds of error records for a database operation
I've written code to be called from Powershell like so:
Rename-DatabaseUser -Name 'someuser' -NewName 'somenewuser'
I'm wondering if there's another way I can ...
1
vote
2answers
174 views
Instantiating shapes using the Factory Design Pattern in Java
Trying to learn the factory design pattern, came up with some code based on a Shape Factory (found this example here). Is this the right way to implement the factory pattern?
...
2
votes
3answers
76 views
Factory to construct a FineTime out of many kinds of objects
Any suggestions to help refactor this method? I thought maybe some kind of factory to allocate the right type?
...
2
votes
1answer
43 views
Generating sample data for a Rails application
I am working on generating sample data for my Rails application. For now we will just be using the sample data while we are designing the website. I'd like it to be as easy as possible to generate ...
2
votes
0answers
55 views
Compile-time plugin system (2)
Background
This is a follow-up of this CR: Compile-time plugin system. The code exposed below can also be browsed on this gist, which shows the differences between both questions (original is version ...
5
votes
1answer
223 views
Compile-time plugin system
Background
For a piece of software that I need to get extensible, I wanted to design a
simple compile-time "plugin" system in C++.
My use case was that the program (actually a library) can accept ...
0
votes
1answer
41 views
Selecting control class in a document assembler
I feel like there is a cleaner/simpler way of doing the following. Is there an existing software pattern that I should be using?
I have an Assembler class that I ...
3
votes
1answer
149 views
Factory pattern in F# for a web scraper
I'm trying to learn F# by creating a little web scraper that will do custom scraping based on the url domain. For this, I need to create and select the correct kind of scraper. I figure I would use a ...
3
votes
1answer
84 views
Creating a lightweight strongly-typed parameter infrastructure
I'm looking for some feedback on some code, designed to allow me to strongly-type parameters, which get passed to functions.
I'm only really looking for comments on making my parameters more strongly ...
10
votes
2answers
98 views
“Drone Racer” now shipping in your local area
This question is a follow-up of this one; where I present a software to plan and manage drone races. I might come with a new question about the SQL part in a few days as well.
The code can still be ...
5
votes
1answer
76 views
Polymorphic TLV serialization
Inspired by this question I decided to write an alternative that uses polymorhphism and a Factory pattern. The code works for the subset of implemented types, namely ...
6
votes
4answers
340 views
Simple factory retrieving object by name [closed]
Despite the fact that this code works, I would like to know if there's any situation I did not anticipated, and/or if what I am trying to do is some what wrong.
-std=C++11 flag needed
...
3
votes
0answers
78 views
Angular OOP services and caching
I've created a caching service using OOP techniques combined with the revealing module pattern and the angular-cache library. New CacheDataClass objects are ...
3
votes
0answers
71 views
Threadsafe singleton factory to use in Apache thrift server RPC system
My goal was to write a factory that the code did not have to be edited. Thus I am registering my factory functions into a singleton factory. I am going to be using this code in Apache thrift server ...
2
votes
1answer
167 views
Enforce what is passed to an activity in an intent similar to the newInstance pattern for fragments
For fragments I have this code to create a new instance:
...
4
votes
2answers
79 views
Simple Translation Gem
I have a small gem that I've been maintaining. This gem provides a simple way to do translation using an alternative Google API.
I've been working with Java last year and recently did some ...
4
votes
1answer
89 views
Factory that creates a complex object tree
I've got a complex object tree that I need to instantiate. The object tree is a bunch of specialized classes that don't have a common root object (other than Object) and has generic objects (that I ...
2
votes
1answer
110 views
Workflow class with Start(), Continue(), and Resume() methods
I have a session class that needs to be setup based on different needs of the client code. Sometimes a new session needs to be created, or continued, or resumed (loaded from database after a user has ...
1
vote
1answer
49 views
Interfaces & Factory for generic container supporting PeekMax, PeekMin, Sum, and PeekNextToMax
This is a partial update of this question.
An implementation of these interfaces is in this question.
To summarize, the class is a generic container similar to MaxHeap, but only needs to support the ...
1
vote
1answer
226 views
Factory dependency injector
I recently made the switch from procedural to OOP style of coding. I decided I wanted to learn how everything works before deciding to jump into a framework, follow tutorials, and becoming dependent ...
3
votes
1answer
351 views
Singleton base class
I just wrote a singleton base class for a hobby project I'm currently working on. Python is not my first language, which is why I am not sure if everything is done the pythonic way.
I also used ...
4
votes
1answer
112 views
Create Java object from from page content or plain text
My job is to make a specified java objects from web page that contains following text:
Companies:
...
5
votes
1answer
119 views
Python factory method with easy registry
My aim is to define a set of classes, each providing methods for comparing a particular type of file. My idea is to use some kind of factory method to instantiate the class based upon a string, which ...
2
votes
1answer
471 views
Replacing IUnitOfWork with a Factory Pattern
As a follow-up to this blog post and this question, I wanted to post my idea of replacing the IUnitOfWork with a factory pattern. It seems to me that in the case of this blog post the IUnitOfWork ...
5
votes
1answer
189 views
Message factory
Today I thought about Factory Design Pattern in Swift, and I do an implementation with Extension.
My post is about if anyone have any observation or issue about this implementation violate any ...
8
votes
4answers
1k views
Creating unique registration numbers using object factories
I'm learning about immutability and uniqueness in Java, particularly the use of defensive programming and object factories.
I have been asked to create a class containing an object factory that when ...
2
votes
1answer
619 views
Implementation of MVC Bootstrap & Factory
Before I get started, I feel I need to list the following.
I am not looking for an existing DI or Framework this is a personal project to shift from procedural to oop programming.
Tear this apart. I ...