Click here to Skip to main content
13,053,891 members (58,666 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: conscious perma-coupling Pin
Jacek Gajek30-Apr-14 22:18
memberJacek Gajek30-Apr-14 22:18 
GeneralRtf -WTF: why is it different? Pin
Bernhard Hiller15-Apr-14 4:56
professionalBernhard Hiller15-Apr-14 4:56 
GeneralRe: Rtf -WTF: why is it different? Pin
ledtech315-Apr-14 5:11
memberledtech315-Apr-14 5:11 
GeneralRe: Rtf -WTF: why is it different? Pin
Bernhard Hiller15-Apr-14 20:55
professionalBernhard Hiller15-Apr-14 20:55 
GeneralRe: Rtf -WTF: why is it different? Pin
ledtech316-Apr-14 4:28
memberledtech316-Apr-14 4:28 
GeneralRe: Rtf -WTF: why is it different? Pin
Rob Grainger16-Apr-14 0:08
memberRob Grainger16-Apr-14 0:08 
GeneralRe: Rtf -WTF: why is it different? Pin
Manikandan1011-Jun-14 3:31
professionalManikandan1011-Jun-14 3:31 
General#region Pin
Bernhard Hiller11-Apr-14 2:51
professionalBernhard Hiller11-Apr-14 2:51 
Sometimes I have the impression to work for Augeas[^] Stables Inc, but actually I am expected to produce more dung than to get rid of it...
In the 13395 lines of code of the main window of one of our applications, I found this little gem (really little - only 320 loc) whose functionality I'll need in a new application (a little anonymized):
        /// <summary>
        /// some description
        /// </summary>
        private void DoSomething()
        {
            ...
            #region do X
            ...
            #endregion
 
            #region do Y
            ...
            #endregion
 
            #region do Z
            ...
            #endregion
 
            #region do A
            ...
            #endregion
 
            #region do B
            if (some condition)
            {
                #region do C
                ...
                #endregion
            }
            else
            {
                #region do D
                ...
                #endregion
            }
            #endregion
            ...
            #region do E
            try
            {
                switch (some swicth)
                {
                    #region do F
                    case ...
                        break;
                    #endregion
                    #region do G
                    case ...
                        break;
                    #endregion
                    #region do H
                    case ...
                        break;
                    #endregion
                    #region do I
                    case ...
                        break;
                    #endregion
                }
                ...
            #endregion
        }

Of course with some extra try...catch inside the regions or other try...catch.
Well, at least, it looks like the functionality I need to transfer to the new application is - with the exception of some member variables - in that one single function, and not scattered all over the class... Wink | ;)
"Have you heard of 'Clean Code' by Robert C. Martin? You can download it from the web", said the guy who uses to write such functions.
GeneralRe: #region Pin
tgrt11-Apr-14 3:58
membertgrt11-Apr-14 3:58 
GeneralRe: #region Pin
OriginalGriff11-Apr-14 5:41
protectorOriginalGriff11-Apr-14 5:41 
GeneralRe: #region Pin
Bernhard Hiller13-Apr-14 20:40
professionalBernhard Hiller13-Apr-14 20:40 
GeneralRe: #region Pin
OriginalGriff13-Apr-14 21:00
protectorOriginalGriff13-Apr-14 21:00 
GeneralRe: #region Pin
Brisingr Aerowing11-Apr-14 5:46
professionalBrisingr Aerowing11-Apr-14 5:46 
GeneralRe: #region Pin
Shameel21-Apr-14 0:57
memberShameel21-Apr-14 0:57 
GeneralRe: #region Pin
BobJanova11-Apr-14 6:51
memberBobJanova11-Apr-14 6:51 
GeneralRe: #region Pin
Richard Andrew x6411-Apr-14 8:29
professionalRichard Andrew x6411-Apr-14 8:29 
JokeRe: #region Pin
Sander Rossel24-Apr-14 7:33
memberSander Rossel24-Apr-14 7:33 
GeneralRe: #region Pin
Giuseppe Tollini24-May-14 1:05
memberGiuseppe Tollini24-May-14 1:05 
GeneralRe: #region Pin
Bernhard Hiller29-May-14 20:59
professionalBernhard Hiller29-May-14 20:59 
GeneralHow not to create an instance of a singleton Pin
Dennis_E10-Apr-14 23:59
professionalDennis_E10-Apr-14 23:59 
JokeRe: How not to create an instance of a singleton Pin
Nicholas Marty11-Apr-14 0:25
professionalNicholas Marty11-Apr-14 0:25 
GeneralRe: How not to create an instance of a singleton Pin
Marc Clifton11-Apr-14 1:40
protectorMarc Clifton11-Apr-14 1:40 
GeneralRe: How not to create an instance of a singleton Pin
Nicholas Marty11-Apr-14 3:16
professionalNicholas Marty11-Apr-14 3:16 
GeneralRe: How not to create an instance of a singleton Pin
Marc Clifton11-Apr-14 4:52
protectorMarc Clifton11-Apr-14 4:52 
GeneralRe: How not to create an instance of a singleton Pin
Dennis_E24-Apr-14 1:16
professionalDennis_E24-Apr-14 1:16 

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
Web02 | 2.8.170713.1 | Last Updated 27 Jul 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid