Click here to Skip to main content
15,127,128 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 16:45
cofounderChris Maunder17-Feb-16 16:45 
GeneralRe: Oh, that ol' Cthulhu sure is sneaky... Pin
V.17-Feb-16 20:53
professionalV.17-Feb-16 20:53 
GeneralRe: Oh, that ol' Cthulhu sure is sneaky... Pin
Ed Bouras22-Feb-16 3:59
MemberEd Bouras22-Feb-16 3:59 
GeneralRe: Oh, that ol' Cthulhu sure is sneaky... Pin
OriginalGriff18-Feb-16 5:13
mveOriginalGriff18-Feb-16 5:13 
GeneralIs this bad? Pin
James_Parsons17-Feb-16 3:07
MemberJames_Parsons17-Feb-16 3:07 
GeneralRe: Is this bad? Pin
Tim Carmichael17-Feb-16 3:31
MemberTim Carmichael17-Feb-16 3:31 
GeneralRe: Is this bad? Pin
Nish Nishant17-Feb-16 4:13
sitebuilderNish Nishant17-Feb-16 4:13 
GeneralStyle Guide for Obfuscation? Pin
Bernhard Hiller10-Feb-16 23:30
MemberBernhard Hiller10-Feb-16 23: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 2:23
mveRichard Deeming11-Feb-16 2:23 
GeneralRe: Style Guide for Obfuscation? Pin
Bernhard Hiller11-Feb-16 3:31
MemberBernhard Hiller11-Feb-16 3:31 
GeneralRe: Style Guide for Obfuscation? Pin
Richard Deeming11-Feb-16 3:36
mveRichard Deeming11-Feb-16 3:36 
GeneralRe: Style Guide for Obfuscation? Pin
#realJSOP11-Feb-16 3:38
mva#realJSOP11-Feb-16 3:38 
GeneralRe: Style Guide for Obfuscation? Pin
RugbyLeague11-Feb-16 4:58
MemberRugbyLeague11-Feb-16 4:58 
GeneralRe: Style Guide for Obfuscation? Pin
Nish Nishant17-Feb-16 4:16
sitebuilderNish Nishant17-Feb-16 4:16 
Generaltesting 1.2.3. Pin
Duncan Edwards Jones9-Feb-16 2:06
professionalDuncan Edwards Jones9-Feb-16 2:06 
GeneralRe: testing 1.2.3. Pin
F-ES Sitecore9-Feb-16 3:50
mveF-ES Sitecore9-Feb-16 3:50 
GeneralRe: testing 1.2.3. Pin
Rob Grainger15-Feb-16 1:41
MemberRob Grainger15-Feb-16 1:41 
GeneralIntellisense Strikes Again Pin
Foothill5-Feb-16 9:00
professionalFoothill5-Feb-16 9:00 
GeneralRe: Intellisense Strikes Again Pin
PIEBALDconsult5-Feb-16 10:00
professionalPIEBALDconsult5-Feb-16 10:00 
GeneralRe: Intellisense Strikes Again Pin
Brisingr Aerowing5-Feb-16 10:01
professionalBrisingr Aerowing5-Feb-16 10:01 
GeneralRe: Intellisense Strikes Again Pin
kmoorevs6-Feb-16 6:04
Memberkmoorevs6-Feb-16 6:04 
GeneralRe: Intellisense Strikes Again Pin
Brisingr Aerowing6-Feb-16 6:10
professionalBrisingr Aerowing6-Feb-16 6:10 
GeneralRe: Intellisense Strikes Again Pin
wout de zeeuw5-Feb-16 13:11
Memberwout de zeeuw5-Feb-16 13:11 
GeneralRe: Intellisense Strikes Again Pin
Brisingr Aerowing5-Feb-16 13:52
professionalBrisingr Aerowing5-Feb-16 13:52 
GeneralRe: Intellisense Strikes Again Pin
wout de zeeuw5-Feb-16 14:02
Memberwout de zeeuw5-Feb-16 14: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.