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
35 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 ...
0
votes
0answers
36 views
Return Class based on Interface and Enum [closed]
I have a number of classes that implement one or more interfaces. I need to be able to retrieve the correct class corresponding to a given Enum value, but as a type of a specific interface.
Classes
...
5
votes
1answer
99 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
330 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 ...
0
votes
1answer
117 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
65 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
55 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
75 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
82 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 ...
4
votes
1answer
265 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
116 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
177 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 ...
5
votes
4answers
2k 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
100 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
2answers
80 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
116 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
194 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
190 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
311 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
131 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
208 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
63 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
90 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
55 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
69 views
5
votes
2answers
185 views
1
vote
2answers
80 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
64 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
2k 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
84 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
466 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
103 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
103 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
130 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 ...
2
votes
1answer
158 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
294 views
using (IDisposable) in c# factory pattern
How will this example affect the using implementation in GetSite?
...
4
votes
2answers
798 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
165 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
194 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
136 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
255 views
Is this a correct way to use Factory Pattern?
I have an abstract class which implements the IDataCreator interface:
...
8
votes
3answers
536 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 ...