Click here to Skip to main content

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, embarrasing 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: Thinking Inside the Box PinprofessionalArgonia30-Apr-14 6:00 
GeneralRe: Thinking Inside the Box PinmvpRyanDev29-Apr-14 13:52 
Generalconscious perma-coupling PinprofessionalDuncan Edwards Jones20-Apr-14 13:17 
GeneralRe: conscious perma-coupling PinmemberShameel21-Apr-14 1:53 
GeneralRe: conscious perma-coupling PinmemberBobJanova22-Apr-14 0:58 
GeneralRe: conscious perma-coupling PinprofessionalDuncan Edwards Jones22-Apr-14 1:10 
GeneralRe: conscious perma-coupling PinmemberJacek Gajek30-Apr-14 23:18 
GeneralRtf -WTF: why is it different? PinprofessionalBernhard Hiller15-Apr-14 5:56 
GeneralRe: Rtf -WTF: why is it different? Pinmemberledtech315-Apr-14 6:11 
GeneralRe: Rtf -WTF: why is it different? PinprofessionalBernhard Hiller15-Apr-14 21:55 
GeneralRe: Rtf -WTF: why is it different? Pinmemberledtech316-Apr-14 5:28 
GeneralRe: Rtf -WTF: why is it different? PinmemberRob Grainger16-Apr-14 1:08 
GeneralRe: Rtf -WTF: why is it different? PinprofessionalManikandan1011-Jun-14 4:31 
General#region PinprofessionalBernhard Hiller11-Apr-14 3: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 Pinmembertgrt11-Apr-14 4:58 
GeneralRe: #region PinprotectorOriginalGriff11-Apr-14 6:41 
GeneralRe: #region PinprofessionalBernhard Hiller13-Apr-14 21:40 
GeneralRe: #region PinprotectorOriginalGriff13-Apr-14 22:00 
GeneralRe: #region PinprofessionalBrisingr Aerowing11-Apr-14 6:46 
GeneralRe: #region PinmemberShameel21-Apr-14 1:57 
GeneralRe: #region PinmemberBobJanova11-Apr-14 7:51 
GeneralRe: #region PinprofessionalRichard Andrew x6411-Apr-14 9:29 
JokeRe: #region PinmemberSander Rossel24-Apr-14 8:33 
GeneralRe: #region PinmemberGiuseppe Tollini24-May-14 2:05 
GeneralRe: #region PinprofessionalBernhard Hiller29-May-14 21:59 
GeneralHow not to create an instance of a singleton PinprofessionalDennis_E11-Apr-14 0:59 
JokeRe: How not to create an instance of a singleton PinprofessionalNicholas Marty11-Apr-14 1:25 
GeneralRe: How not to create an instance of a singleton PinprotectorMarc Clifton11-Apr-14 2:40 
GeneralRe: How not to create an instance of a singleton PinprofessionalNicholas Marty11-Apr-14 4:16 
GeneralRe: How not to create an instance of a singleton PinprotectorMarc Clifton11-Apr-14 5:52 
GeneralRe: How not to create an instance of a singleton PinprofessionalDennis_E24-Apr-14 2:16 
GeneralRe: How not to create an instance of a singleton PinprofessionalNicholas Marty24-Apr-14 4:20 
GeneralRe: How not to create an instance of a singleton PinmemberBobJanova11-Apr-14 7:50 
GeneralRe: How not to create an instance of a singleton PinprofessionalBernhard Hiller11-Apr-14 3:21 
GeneralRe: How not to create an instance of a singleton PinprotectorOriginalGriff11-Apr-14 6:42 
GeneralRe: How not to create an instance of a singleton PinmemberJacek Gajek29-Apr-14 11:51 
GeneralThere is nothing new under the sun... PinprofessionalDuncan Edwards Jones9-Apr-14 8:22 
GeneralRe: There is nothing new under the sun... PinmemberI.explore.code9-Apr-14 8:41 
GeneralRe: There is nothing new under the sun... PinadminChris Maunder9-Apr-14 8:55 
GeneralRe: There is nothing new under the sun... PinprofessionalKornfeld Eliyahu Peter9-Apr-14 11:05 
GeneralRe: There is nothing new under the sun... PinmemberRob Grainger11-Apr-14 0:30 
GeneralRe: There is nothing new under the sun... PinprofessionalDuncan Edwards Jones11-Apr-14 0:49 
GeneralRe: There is nothing new under the sun... PinmemberSander Rossel24-Apr-14 8:42 
GeneralHow not to do transaction processing PinmemberRob Grainger9-Apr-14 7:12 
GeneralRe: How not to do transaction processing PinprofessionalDuncan Edwards Jones9-Apr-14 8:13 
GeneralRe: How not to do transaction processing PinmemberRob Grainger10-Apr-14 5:12 
GeneralRe: How not to do transaction processing PinmemberW Balboos11-Apr-14 2:14 
GeneralRe: How not to do transaction processing Pinmemberclawton9-Apr-14 13:30 
GeneralRe: How not to do transaction processing PinmemberBobJanova10-Apr-14 0:39 
GeneralRe: How not to do transaction processing PinmemberRob Grainger10-Apr-14 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.141223.1 | Last Updated 28 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid