+dave164 Subscriber¹ Posted March 23, 2009 Subscriber¹ Share Posted March 23, 2009 Hey guys, I'm struggling a little bit with understanding factory methods. Am I right in thinking that it is where you implement the singleton method and ensure you only have one instance of the object? Thanks, David Link to comment Share on other sites More sharing options...
0 Andre S. Veteran Posted March 23, 2009 Veteran Share Posted March 23, 2009 Any method whose responsibility is to create objects is a factory method. The getInstance() method of a Singleton would be, indeed, some kind of a factory method, although the typical pattern is usually a method that can create different objects based on some parameters. See http://en.wikipedia.org/wiki/Factory_method_pattern Link to comment Share on other sites More sharing options...
0 _kane81 Posted March 23, 2009 Share Posted March 23, 2009 Factories don't have to be singleton, but usually they are... case might be computer factory where constructor arg is country name....but of course you could make singleton, by adding the arg to method call Link to comment Share on other sites More sharing options...
0 +dave164 Subscriber¹ Posted March 23, 2009 Author Subscriber¹ Share Posted March 23, 2009 Thanks guys, i've got it working great. David Link to comment Share on other sites More sharing options...
Question
+dave164 Subscriber¹
Hey guys,
I'm struggling a little bit with understanding factory methods.
Am I right in thinking that it is where you implement the singleton method and ensure you only have one instance of the object?
Thanks,
David
Link to comment
Share on other sites
3 answers to this question
Recommended Posts