Click here to Skip to main content
16,004,906 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: singleton pattern example Pin
led mike4-Sep-07 5:03
led mike4-Sep-07 5:03 
JokeRe: singleton pattern example Pin
Colin Angus Mackay4-Sep-07 9:13
Colin Angus Mackay4-Sep-07 9:13 
AnswerRe: singleton pattern example Pin
Colin Angus Mackay4-Sep-07 13:08
Colin Angus Mackay4-Sep-07 13:08 
AnswerRe: singleton pattern example Pin
Urs Enzler4-Sep-07 21:37
Urs Enzler4-Sep-07 21:37 
GeneralRe: singleton pattern example Pin
Colin Angus Mackay5-Sep-07 4:35
Colin Angus Mackay5-Sep-07 4:35 
GeneralRe: singleton pattern example Pin
Urs Enzler5-Sep-07 4:40
Urs Enzler5-Sep-07 4:40 
GeneralRe: singleton pattern example Pin
led mike5-Sep-07 6:24
led mike5-Sep-07 6:24 
GeneralRe: singleton pattern example Pin
Urs Enzler5-Sep-07 7:04
Urs Enzler5-Sep-07 7:04 
Yes of course, I'm a bit exaggerating Smile | :)

The main reason I'm not a fan of the singleton pattern is because it is overused.

1)
The decision that something exists only once in an application is a very final one. Normally singletons are very basic things in an application (a logger for example). And if that changes (happend about three times to a project I was working in) it is very hard to refactor (because of point 2)

2)
It is often the case that projects using singletons are not loosly coupled: components reference the singleton by something like MySingletonClass.Instance. I consider this very limiting. In an earlier post I mentioned that I use a Manager pattern (or Factory pattern) that allows me to exchagne the real object behind the "singleton" for example for testing (mocks).

3)
In a framework or in a base components library, you should definitly not use singletons because they can not be replaced by project specific instances.

Because of these reasons I prefer using a manager pattern (Factory pattern) because it is not really more complicated but very much more flexible and not limited.

And as a final word: yes there are situations where the singleton pattern is adequat, but they are seldom in my eyes or there exists a better pattern for the scenario.

-^-^-^-^-^-
no risk no funk ................... please vote ------>

GeneralRe: singleton pattern example Pin
led mike5-Sep-07 7:27
led mike5-Sep-07 7:27 
GeneralRe: singleton pattern example Pin
Urs Enzler5-Sep-07 7:51
Urs Enzler5-Sep-07 7:51 
GeneralRe: singleton pattern example Pin
led mike5-Sep-07 8:07
led mike5-Sep-07 8:07 
GeneralRe: singleton pattern example Pin
Urs Enzler5-Sep-07 20:19
Urs Enzler5-Sep-07 20:19 
AnswerRe: singleton pattern example Pin
hotcodeking5-Sep-07 1:58
hotcodeking5-Sep-07 1:58 
AnswerRe: singleton pattern example [modified] Pin
ElSpinos13-Sep-07 23:00
ElSpinos13-Sep-07 23:00 
AnswerRe: singleton pattern example Pin
etkid8421-Sep-07 3:02
etkid8421-Sep-07 3:02 
QuestionApplications communication Pin
Yoav Zur28-Aug-07 19:18
Yoav Zur28-Aug-07 19:18 
AnswerRe: Applications communication Pin
led mike30-Aug-07 4:43
led mike30-Aug-07 4:43 
QuestionClass design help Pin
rsaint2727-Aug-07 3:18
rsaint2727-Aug-07 3:18 
GeneralRe: Class design help Pin
Paul Conrad27-Jan-08 7:12
professionalPaul Conrad27-Jan-08 7:12 
QuestionPromotion Table Schema Design Pin
yameen26-Aug-07 3:48
yameen26-Aug-07 3:48 
GeneralRe: Promotion Table Schema Design Pin
Paul Conrad27-Jan-08 7:13
professionalPaul Conrad27-Jan-08 7:13 
Questiongetting infragistics Pin
starist24-Aug-07 9:28
starist24-Aug-07 9:28 
AnswerRe: getting infragistics Pin
Mark Churchill2-Sep-07 19:11
Mark Churchill2-Sep-07 19:11 
GeneralRe: getting infragistics Pin
TAHIR MURAD3-Sep-07 1:06
TAHIR MURAD3-Sep-07 1:06 
GeneralRe: getting infragistics Pin
originSH3-Sep-07 23:36
originSH3-Sep-07 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.