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
1answer
71 views
Naming factories
Given the code below, I'm curious to know if you'd have better naming suggestions for types:
VegetablePresentersFactory
VegetablePresenterFactory
It bothers me a bit that their names only differ ...
1
vote
0answers
31 views
Why is entangling injectable with class that uses it a bad practice? [migrated]
I have had this argument for a while, because I have noticed some people prefer "readable" code over properly structured one. So in the example I am showing, basically I have this ...
0
votes
0answers
27 views
Avoid construction of new objects if the class can operate stateless [closed]
Let's say I have a factory like this (it's from an interview):
...
4
votes
1answer
106 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
48 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 ...
0
votes
0answers
21 views
Using Rvalue references and Simple Factory [migrated]
I recently learnt about std::move and rvalue references, and want to know if my usage of them is both appropriate and efficient.
...
2
votes
1answer
78 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 ...
5
votes
1answer
104 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
25 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
52 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 ...
3
votes
1answer
65 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 ...
0
votes
0answers
47 views
Am I breaking Open/Closed Principle with the factory method? [duplicate]
I believe I'm implementing a factory method for my DAO. I have three different types of DAO: SQL, Serial, RAM, and each have their own subtypes. Would I be better off with an abstract factory method ...
4
votes
1answer
49 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
61 views
5
votes
2answers
153 views
1
vote
2answers
69 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
60 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:
...
3
votes
2answers
463 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
79 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
300 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 ...
0
votes
0answers
40 views
Classes to iterate over millions of records, performing calculations and comparisons on each
I'm converting a PHP written with a lot of procedural loops to classes. There is a hierarchy of nested information represented in nested associative arrays. The actual records are from currency ...
5
votes
1answer
86 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
88 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
108 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
76 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
194 views
using (IDisposable) in c# factory pattern
How will this example affect the using implementation in GetSite?
...
1
vote
0answers
71 views
OOP Programming Methods [closed]
I have an OOP program started actually in many different ways. First way is the literal method,
...
5
votes
2answers
699 views
“Fancy-pants” vs “Cowboy” coding
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
155 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
168 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
113 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, ...
2
votes
1answer
731 views
5
votes
2answers
232 views
Is this a correct way to use Factory Pattern?
I have an abstract class which implements the IDataCreator interface:
...
7
votes
3answers
509 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 ...