The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
2answers
441 views

When is it worth NOT using a Factory?

I'm employing TDD quite a bit these days and really enjoying myself - everything seems to flow better and be naturally better constructed and organized. However, while writing a bit of IO code, ...
0
votes
1answer
86 views

Using factory pattern when classes have little in common

I have used Factory pattern where I have multiple classes which does similar sort of work, but I don't want client to worry about class instantiating and return types. So Instantiate the necessary ...
1
vote
1answer
131 views

Differentiating between Factory Method and Abstract Factory

I've been confused for a while about the differences between the patterns Factory Method and Abstract Factory. Been doing a lot of research, still confused. I have one question: Is the only ...
0
votes
2answers
188 views

Factory Method vs. Factory Method design pattern

I am currently studying design patterns from the book (which, although I didn't try anything else, I find excellent) Head First Design Patterns. I'm confused about two concepts: The Factory Method, ...
0
votes
1answer
123 views

Why can't the Factory Method pattern create a family of objects? [duplicate]

There are two main differences between the design patterns Factory Method and Abstract Factory. Difference 1 is that Factory Method is mainly based on inheritance. A class in a way uses it's subclass ...
3
votes
3answers
140 views

Why should one subclass instead of composite when using the Factory Method design pattern?

I'm currently learning about design patterns. I learned about the Factory Method pattern. This pattern means that in order to implement a factory to create objects, one should subclass the class that ...
0
votes
0answers
57 views

Is Factory method subclass of Abstract factory in essence [duplicate]

Is it correct to say that factory method is essentially just a particular case of the abstract factory which produces the only one object not a group? I know that classic realizations assumes the ...
12
votes
3answers
3k views

Static factory vs factory as a singleton

In some of my code, I have a static factory similar to this: public class SomeFactory { // Static class private SomeFactory() {...} public static Foo createFoo() {...} public ...
1
vote
1answer
276 views

Is a Factory class still a Factory class if the objects it returns already exist?

I can't decide what to name my class. So far I've labelled it up as a Factory, but I am not sure. Here is the class. As you can see, it exists to return a concrete type of an Interface ...
1
vote
3answers
284 views

Better solution then simple factory method when concrete implementations have different attributes

abstract class Animal { function eat() {..} function sleep() {..} function isSmart() } class Dog extends Animal { public $blnCanBark; function isSmart() { return $this->blnCanBark; ...
2
votes
1answer
491 views

Is there a factory pattern to prevent multiple instances for same object (instance that is Equal) good design?

I have a number of objects storing state. There are essentially two types of fields. The ones that uniquely define what the object is (what node, what edge etc), and the others that store state ...
12
votes
2answers
664 views

I should have used a factory method instead of a constructor. Can I change that and still be backwards-compatible?

The problem Let's say I have a class called DataSource which provides a ReadData method (and maybe others, but let's keep things simple) to read data from an .mdb file: var source = new ...