Click here to Skip to main content
12,079,091 members (48,434 online)

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: #region Pin
BobJanova11-Apr-14 7:51
memberBobJanova11-Apr-14 7:51 
GeneralRe: #region Pin
Richard Andrew x6411-Apr-14 9:29
professionalRichard Andrew x6411-Apr-14 9:29 
JokeRe: #region Pin
Sander Rossel24-Apr-14 8:33
memberSander Rossel24-Apr-14 8:33 
GeneralRe: #region Pin
Giuseppe Tollini24-May-14 2:05
memberGiuseppe Tollini24-May-14 2:05 
GeneralRe: #region Pin
Bernhard Hiller29-May-14 21:59
professionalBernhard Hiller29-May-14 21:59 
GeneralHow not to create an instance of a singleton Pin
Dennis_E11-Apr-14 0:59
professionalDennis_E11-Apr-14 0:59 
JokeRe: How not to create an instance of a singleton Pin
Nicholas Marty11-Apr-14 1:25
professionalNicholas Marty11-Apr-14 1:25 
GeneralRe: How not to create an instance of a singleton Pin
Marc Clifton11-Apr-14 2:40
protectorMarc Clifton11-Apr-14 2:40 
Which of course is used like this:

SingletonClass myVerySingletonClass = (new SingletonClass()).getInstance();

or even better:

SingletonClass anInstanceThatWeDontUse = new SingletoneClass();
SingletonClass useThisInstead = anInstanceThatWeDontUse.getInstance();

Good stuff! Laugh | :laugh:

On the other hand, I actually have written code similar to this, except I don't call it a singleton of course. Granted, it's smelly code.

Quiz: What might be the reason to provide a static method that returns an instance of the class, when you know that there will ever only be one instance?

Marc
GeneralRe: How not to create an instance of a singleton Pin
Nicholas Marty11-Apr-14 4:16
professionalNicholas Marty11-Apr-14 4:16 
GeneralRe: How not to create an instance of a singleton Pin
Marc Clifton11-Apr-14 5:52
protectorMarc Clifton11-Apr-14 5:52 
GeneralRe: How not to create an instance of a singleton Pin
Dennis_E24-Apr-14 2:16
professionalDennis_E24-Apr-14 2:16 
GeneralRe: How not to create an instance of a singleton Pin
Nicholas Marty24-Apr-14 4:20
professionalNicholas Marty24-Apr-14 4:20 
GeneralRe: How not to create an instance of a singleton Pin
BobJanova11-Apr-14 7:50
memberBobJanova11-Apr-14 7:50 
GeneralRe: How not to create an instance of a singleton PinPopular
Bernhard Hiller11-Apr-14 3:21
professionalBernhard Hiller11-Apr-14 3:21 
GeneralRe: How not to create an instance of a singleton Pin
OriginalGriff11-Apr-14 6:42
protectorOriginalGriff11-Apr-14 6:42 
GeneralRe: How not to create an instance of a singleton Pin
Jacek Gajek29-Apr-14 11:51
memberJacek Gajek29-Apr-14 11:51 
GeneralThere is nothing new under the sun... Pin
Duncan Edwards Jones9-Apr-14 8:22
professionalDuncan Edwards Jones9-Apr-14 8:22 
GeneralRe: There is nothing new under the sun... Pin
I.explore.code9-Apr-14 8:41
memberI.explore.code9-Apr-14 8:41 
GeneralRe: There is nothing new under the sun... Pin
Chris Maunder9-Apr-14 8:55
adminChris Maunder9-Apr-14 8:55 
GeneralRe: There is nothing new under the sun... Pin
Kornfeld Eliyahu Peter9-Apr-14 11:05
professionalKornfeld Eliyahu Peter9-Apr-14 11:05 
GeneralRe: There is nothing new under the sun... Pin
Rob Grainger11-Apr-14 0:30
memberRob Grainger11-Apr-14 0:30 
GeneralRe: There is nothing new under the sun... Pin
Duncan Edwards Jones11-Apr-14 0:49
professionalDuncan Edwards Jones11-Apr-14 0:49 
GeneralRe: There is nothing new under the sun... Pin
Sander Rossel24-Apr-14 8:42
memberSander Rossel24-Apr-14 8:42 
GeneralHow not to do transaction processing Pin
Rob Grainger9-Apr-14 7:12
memberRob Grainger9-Apr-14 7:12 
GeneralRe: How not to do transaction processing Pin
Duncan Edwards Jones9-Apr-14 8:13
professionalDuncan Edwards Jones9-Apr-14 8:13 

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.


Advertise | Privacy | Mobile
Web04 | 2.8.160212.1 | Last Updated 14 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid