'Factory' pattern?
-
I heard someone talks about 'Factory' pattern, but in the GoF book, I just find 'Abstract Factory' & 'Factory Method' pattern. Is there really a pattern named 'Factory', or it's just something in Java?
This is really just a contraction of the Factory patterns. Basically, we have Concrete and Abstract Factory patterns.
Deja View - the feeling that you've seen this post before.
-
I heard someone talks about 'Factory' pattern, but in the GoF book, I just find 'Abstract Factory' & 'Factory Method' pattern. Is there really a pattern named 'Factory', or it's just something in Java?
Yes, of course there is factory pattern. It's something like this:
== == = \_\_ || ||
/|/|/|/ |/|
| [] [] |
| |Slow day at work, eh. :-O
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
-
I heard someone talks about 'Factory' pattern, but in the GoF book, I just find 'Abstract Factory' & 'Factory Method' pattern. Is there really a pattern named 'Factory', or it's just something in Java?
flyingxu wrote:
Is there really a pattern named 'Factory', or it's just something in Java?
Yup, software patterns are language independent.. see it as a concept with a name, it makes commucation between developers easier (once they know the meaning of a pattern). Here one example of use for a factory in C++: A plugin (in form of a shared library) has typically one static function in a DLL that creates and returns a new plugin instance/object to the caller. Hope it helps.
-
I heard someone talks about 'Factory' pattern, but in the GoF book, I just find 'Abstract Factory' & 'Factory Method' pattern. Is there really a pattern named 'Factory', or it's just something in Java?
Yes you can create a class which can provide you the desired objects. such class can be a Factory. Stack *pStack = CFactory::GetStack(n); where n -> type of stack. Sameer();