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.
1
vote
0answers
46 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
1answer
89 views
Implementation on “Factory Method Pattern”
I am learning design patterns.
I started learning factory pattern, and also implemented factory method pattern.
So my factory-method pattern classes are as follows:
There are two major parts, an ...
3
votes
0answers
59 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
62 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
26 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
0answers
30 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
94 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
507 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
58 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
52 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
38 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
63 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--...
3
votes
2answers
133 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
50 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
132 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
35 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
33 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
117 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
105 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
82 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 ...
9
votes
2answers
86 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
64 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
278 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
75 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
56 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
102 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
75 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
73 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
93 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
45 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
224 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
266 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
108 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
114 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
297 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
179 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
929 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
492 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
85 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
149 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
122 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
334 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
994 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
13k 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
370 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 ...