Click here to Skip to main content
15,860,943 members

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: Oh, that ol' Cthulhu sure is sneaky... Pin
Chris Maunder17-Feb-16 15:45
cofounderChris Maunder17-Feb-16 15:45 
GeneralRe: Oh, that ol' Cthulhu sure is sneaky... Pin
V.17-Feb-16 19:53
professionalV.17-Feb-16 19:53 
GeneralRe: Oh, that ol' Cthulhu sure is sneaky... Pin
Middle Manager22-Feb-16 2:59
Middle Manager22-Feb-16 2:59 
GeneralRe: Oh, that ol' Cthulhu sure is sneaky... Pin
OriginalGriff18-Feb-16 4:13
mveOriginalGriff18-Feb-16 4:13 
GeneralIs this bad? Pin
James_Parsons17-Feb-16 2:07
James_Parsons17-Feb-16 2:07 
GeneralRe: Is this bad? Pin
Tim Carmichael17-Feb-16 2:31
Tim Carmichael17-Feb-16 2:31 
GeneralRe: Is this bad? Pin
Nish Nishant17-Feb-16 3:13
sitebuilderNish Nishant17-Feb-16 3:13 
GeneralStyle Guide for Obfuscation? Pin
Bernhard Hiller10-Feb-16 22:30
Bernhard Hiller10-Feb-16 22:30 
A colleague told me about a great bugfixing experience: a local variable had the same name as a member variable. "But the compiler will show you a warning." - "No, it does not."
Hard to believe, hence I tried it with a very simple class. My colleague was right: there is no compiler warning when a local variable overwrites a member variable.
But there are some tools which could help us here, like StyleCop. I installed StyleCop, and eventually got it accepting my code:
// <copyright file="DontDoThat.cs" company="blah">blah</copyright>
namespace Nonsense
{
    /// <summary>
    /// Blah blah
    /// </summary>
    public class DontDoThat
    {
        /// <summary>
        /// Blah blah
        /// </summary>
        private int someValue = 0;

        /// <summary>
        /// Blah blah
        /// </summary>
        public void DoSomething()
        {
            if (this.someValue == 0)
            {
                this.DoSomethingElse();
            }
        }

        /// <summary>
        /// Blah blah
        /// </summary>
        private void DoSomethingElse()
        {
            int someValue = 42;
            int somethingElse = someValue * someValue;
        }
    }
}

Well, that's clean code, isn't it? StyleCop suggested great things. Still a local variable can overwrite a member variable, but now you see the difference more clearly: a member variable has a "this." prefix. Hungarian notation is so great. Dead | X|
GeneralRe: Style Guide for Obfuscation? Pin
Richard Deeming11-Feb-16 1:23
mveRichard Deeming11-Feb-16 1:23 
GeneralRe: Style Guide for Obfuscation? Pin
Bernhard Hiller11-Feb-16 2:31
Bernhard Hiller11-Feb-16 2:31 
GeneralRe: Style Guide for Obfuscation? Pin
Richard Deeming11-Feb-16 2:36
mveRichard Deeming11-Feb-16 2:36 
GeneralRe: Style Guide for Obfuscation? Pin
#realJSOP11-Feb-16 2:38
mve#realJSOP11-Feb-16 2:38 
GeneralRe: Style Guide for Obfuscation? Pin
RugbyLeague11-Feb-16 3:58
RugbyLeague11-Feb-16 3:58 
GeneralRe: Style Guide for Obfuscation? Pin
Nish Nishant17-Feb-16 3:16
sitebuilderNish Nishant17-Feb-16 3:16 
Generaltesting 1.2.3. Pin
Duncan Edwards Jones9-Feb-16 1:06
professionalDuncan Edwards Jones9-Feb-16 1:06 
GeneralRe: testing 1.2.3. Pin
F-ES Sitecore9-Feb-16 2:50
professionalF-ES Sitecore9-Feb-16 2:50 
GeneralRe: testing 1.2.3. Pin
Rob Grainger15-Feb-16 0:41
Rob Grainger15-Feb-16 0:41 
GeneralIntellisense Strikes Again Pin
Foothill5-Feb-16 8:00
professionalFoothill5-Feb-16 8:00 
GeneralRe: Intellisense Strikes Again Pin
PIEBALDconsult5-Feb-16 9:00
mvePIEBALDconsult5-Feb-16 9:00 
GeneralRe: Intellisense Strikes Again Pin
Brisingr Aerowing5-Feb-16 9:01
professionalBrisingr Aerowing5-Feb-16 9:01 
GeneralRe: Intellisense Strikes Again Pin
kmoorevs6-Feb-16 5:04
kmoorevs6-Feb-16 5:04 
GeneralRe: Intellisense Strikes Again Pin
Brisingr Aerowing6-Feb-16 5:10
professionalBrisingr Aerowing6-Feb-16 5:10 
GeneralRe: Intellisense Strikes Again Pin
wout de zeeuw5-Feb-16 12:11
wout de zeeuw5-Feb-16 12:11 
GeneralRe: Intellisense Strikes Again Pin
Brisingr Aerowing5-Feb-16 12:52
professionalBrisingr Aerowing5-Feb-16 12:52 
GeneralRe: Intellisense Strikes Again Pin
wout de zeeuw5-Feb-16 13:02
wout de zeeuw5-Feb-16 13:02 

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.