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.

learn more… | top users | synonyms

2
votes
0answers
26 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
71 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
482 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
43 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
46 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
37 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
51 views

Extendable JavaScript module that converts between camelCase, PascalCase, and underscore_case

The basic idea is that by defining the basic functions--recognize, dissect, and combine--...
3
votes
2answers
83 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
48 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
120 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
31 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
28 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
81 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
88 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
80 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 ...
8
votes
2answers
83 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
58 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
261 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
72 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
51 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
77 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
74 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
69 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
86 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
44 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
223 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
240 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
104 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
110 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
229 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
173 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
860 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
452 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. ...
6
votes
1answer
119 views

Use of static factory methods for vectors and matrices library

I've been working on a Java-based mathematics library focusing on vectors and matrices. I plan to use it for an important upcoming project, so the classes are analogous to data types available in GLSL ...
3
votes
1answer
84 views

Using one service ($http) on all the controllers

I have recently started working on angular.js and I like it. I have decided to use a single controller per view. I use the json data from the backend. As my work is progressing, my codes are getting ...
1
vote
1answer
148 views

PHP Factory Method Pattern Implementation

This is an attempt at the Factory Method Pattern It emulates the logical model and also the physical model Resources: http://en.wikipedia.org/wiki/Factory_method_pattern http://msdn.microsoft....
0
votes
1answer
118 views

Factory Pattern Implementation in PHP [closed]

I have read some articles regarding the factory pattern and decided to write some code as an exercise. This is my first attempt and am not 100% if I did it right. I've omitted some implementations for ...
5
votes
1answer
1k views

Using $q in Angular JS to pass navigator geo JSON from factory to controller

This code is used to get the users location and deliver it as a resource to the controller. The aim is to have this data shared across multiple controllers in the application. So far this does deliver ...
6
votes
1answer
314 views

Factory template method for generalized functors

(A quick note on terminology: I use 'generalized functor' to refer to a functor that can be initialized from any callable entity, similar to the definition from Alexandrescu's Modern C++ Design. I use ...
1
vote
2answers
897 views

Avoiding Duplicates in a Ruby on Rails Factory Girl Factory with Fake

I have a Factory Girl factory that needs to generate a unique name using Faker. Unfortunately, Factory Girl generates duplicates relatively frequently, which causes intermittent test errors. I ...
8
votes
4answers
11k views

Using std::unique_ptr and std::move

I'm trying out new things (on class Inproc), specifically using std::unique_ptr and std::move...
2
votes
1answer
340 views

Is there a better design pattern for a SDK?

At work I decided it would be better to reverse engineer a SDK for one of our pieces of hardware. Because it is work related I can't share the exact code.. but I can give enough of a gist of the code ...
1
vote
1answer
89 views

Factory object with a dependency on a bean

My problem is quite straightforward. I want to build a factory, but the kind of object returned depends on a value read from a bean that is somehow a cache. So of course, I can't call the bean's ...
5
votes
2answers
128 views

Naming Vegetable Factories

Given the code below, I'm curious to know if you'd have better naming suggestions for types: VegetablePresentersFactory ...
4
votes
1answer
592 views

Factory pattern with controls

I've created factory to create WPF controls. I have string with control name and I map it to enum. I think it's bad implementation of factory pattern. So please show me where I've made mistake. Main ...
3
votes
2answers
1k views

Implementing a thread-safe factory with caching

I have a ConnectorFactory that creates Connector objects based on parameters like URLs, username and passwords. The ...
3
votes
1answer
2k views

Best way to write generic factory in Java

I need to write a factory of generic converters to produce converters from/to MongoDB objects to/from Java objects. Here is my implementation, it doesn't look good enough to me, so I would like to see ...
6
votes
1answer
154 views

Universal Spreadsheet reader/writer

I have a project that reads spreadsheets as a rectangular list of lists (matrix) transforms the matrix and then writes it to another spreadsheet. I want to be able to read from and write to multiple ...