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.
2
votes
0answers
15 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
44 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
36 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 ...
3
votes
1answer
76 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
72 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
84 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 ...
1
vote
0answers
77 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
136 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
419 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 ...
1
vote
1answer
260 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. ...
4
votes
1answer
86 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
67 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
101 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
...
0
votes
1answer
91 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
586 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
160 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 ...
0
votes
1answer
360 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 ...
6
votes
4answers
5k views
Using std::unique_ptr and std::move
I'm trying out new things (on class Inproc), specifically using std::unique_ptr and ...
2
votes
1answer
158 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
84 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
120 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
314 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
457 views
Correct way of implementing thread safe factory with caching?
I have a ConnectorFactory that creates Connector objects based on parameters like URLs, username and passwords.
The ...
2
votes
1answer
813 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
140 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 ...
1
vote
0answers
340 views
AngularJS factory, return object to be used again in factory
I'm trying to create a wrapper / factory around the cordova media plugin, which requires you to create a new Media object, and then use it again to pause, stop, play, etc it.
The factory + link to ...
3
votes
1answer
70 views
Factory Class for Game World
The world in my strategy game is comprised of a number of towers. At the start of the game, only one tower is generated, and when the player discovers new towers they are created and added to the ...
4
votes
1answer
111 views
Properly using parameterized Factory.Create() method using DI
My factory is using method injection because I thought this was the best way to make it so far. Besides, I doubt it is a good thing after having to call on its ...
4
votes
1answer
59 views
Code for simplifying the creation of Dimension Objects
I have a class that I use to represent a distance called Dimension.
Here is its four constructors:
...
6
votes
1answer
78 views
5
votes
2answers
203 views
1
vote
2answers
88 views
How to write factory classes or functions in JavaScript? [closed]
I find that in Javascript there are many methods of creating an object so what would be the appropriate approach for constructing an object and why.
...
10
votes
1answer
70 views
Methods creating transform functionality on Collections
I have written a few simple-to-be-used methods in Java 8, and am wondering what could be improved upon those:
...
4
votes
2answers
3k views
Java implementation of the Factory Method pattern
I am working on a very simple game and thought it would be a good opportunity to learn and use the Factory Method pattern for creating game objects. I studied the pattern but I'm a bit confused about ...
4
votes
1answer
86 views
Does the class have unnecessary and violating Single responsibility principle method?
I encountered with the following code in the work. The MyItemCoordinator should receive MyItem objects, process them, add them ...
6
votes
1answer
561 views
C++11 Logging Architecture
To create a Logging system for a larger application, I came up with the following draft. The log sinks aren't detailed yet, but the factory method for logger creation and a rough draft of the logger ...
5
votes
1answer
116 views
Abstract factory or inversion of control pattern?
I have several generic methods that use the typeof operator to determine the type of mapper class to create. Eventually this is going to get out of hand.
Can ...
5
votes
1answer
111 views
Anonymous methods, factory methods, threading, and XML input
I have an application which retrieves data from a (potentially) very large XML file. A combination of XMLReader and XDocument seemed to be the only way I could manage the entire thing the way I ...
6
votes
2answers
143 views
Abstract Factory Experiment
While I should probably be using Dependency Injection via Ninject or a similar project, I have been attempting to implement an abstract factory design that would provide me with the following easy to ...
3
votes
1answer
250 views
Extending prototype of given instance from factory method
I created a rubber ball by extending instance of b2Body prototype of Box2D.js. I get the instance from factory method b2World#CreateBody.
...
1
vote
1answer
364 views
using (IDisposable) in c# factory pattern
How will this example affect the using implementation in GetSite?
...
4
votes
2answers
830 views
“Fancy-pants” vs “Cowboy” coding [closed]
Based on the post I made here: RFC on "Factory" code and its responses, and my (inner) response to those responses, I'm beginning to wonder if it would be just as well to simply switch based ...
3
votes
2answers
166 views
RFC on “Factory” code [closed]
This is the first code of this type that I've attempted, so I'm wondering if anybody would be willing to critique it. It's "sort of" (I think) a factory class. I want to keep it as simple as possible ...
1
vote
1answer
205 views
PHP design pattern factory input for products and quotes
I'm working on figuring out the best way to design this so that it's well organized and it seems like the factory design pattern makes sense.
Updated:
What I'm building:
- Pricing calculator
- ...
2
votes
1answer
147 views
General thoughts on the style of this rspec-rails test
Here's a test from a Rails app I'm working on. I want to know if I'm using describe, let, ...
3
votes
1answer
1k views
5
votes
2answers
290 views
Is this a correct way to use Factory Pattern?
I have an abstract class which implements the IDataCreator interface:
...
8
votes
3answers
553 views
Is this correct factory method pattern?
I know that there are many similar questions, but I don't understand most of those questions because I'm not sure if I know what a factory method pattern is.
So, after reading many examples over the ...