singleton vs factory?

Posted by fayer on Stack Overflow See other posts from Stack Overflow or by fayer
Published on 2010-05-03T09:37:45Z Indexed on 2010/05/03 9:48 UTC
Read the original article Hit count: 644

Filed under:
|
|

i've got 3 Log classes that all implements iLog interface:

DatabaseLog
FileLog
ScreenLog

there can only be one instance of them. initially i though of using single pattern for each class but then i thought why not use a factory for instantiation instead, cause then i wont have to create single pattern for each one of them and for all future Log classes.

and maybe someone would want them as multiple objects in the future.

so my questions is: should i use factory or singleton pattern here?

© Stack Overflow or respective owner

Related posts about design-patterns

Related posts about programming