Click here to Skip to main content
15,891,981 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: Apparently there is no limit to naming conventions for method Pin
Keith Barrow5-May-12 12:07
professionalKeith Barrow5-May-12 12:07 
GeneralRe: Apparently there is no limit to naming conventions for method Pin
Gary Wheeler4-May-12 3:03
Gary Wheeler4-May-12 3:03 
GeneralRe: Apparently there is no limit to naming conventions for method Pin
musicdev4-May-12 16:18
musicdev4-May-12 16:18 
GeneralRe: Apparently there is no limit to naming conventions for method Pin
Mohibur Rashid4-May-12 16:24
professionalMohibur Rashid4-May-12 16:24 
GeneralRe: Apparently there is no limit to naming conventions for method Pin
Reza Ahmadi5-May-12 18:26
Reza Ahmadi5-May-12 18:26 
GeneralRe: Apparently there is no limit to naming conventions for method Pin
ARopo10-May-12 5:42
ARopo10-May-12 5:42 
GeneralRe: Apparently there is no limit to naming conventions for method Pin
Florin Jurcovici5-Jun-12 23:10
Florin Jurcovici5-Jun-12 23:10 
GeneralSee the writing on the wall... PinPopular
CDP18022-May-12 22:42
CDP18022-May-12 22:42 
Today I have my code horror hanging on the wall, in form of a printout from the ceiling to the floor. It's from a Win CE application which had been sent to a customer totally untested. Of course it failed miserably. It's almost ironic, but reporting the error in a message box also fails, due to a missing resource assembly. There also is no logging or any other mechanism to record errors. In short: Nobody really knows what's going on, not even the criminal who wrote that program.

The good news: The form that produces the error only has three methods, PageLoad() and two others. PageLoad() is only a few lines long. Initialisation, nothing really problematic. The first of the two other methods also was quite short. No problems here.

And now method #3:

- 350 lines of best spaghetti code rolled in a loop. Whenever this is executed, it will then hang up the entire application until it is done.

- A total of 17 try/catch blocks. Most catch blocks are totally empty. There is no error handling. The errors are simply swept under the rug and the code goes on as if nothing happened. Only three try to at least show the error in a message box, but our friend also failed at doing that. A brief scan of the rest of the application's code revealed that this is one of his favorite practices.

- There are eight code sequences which appear redundantly in this spaghetti monster. They could easily have been refactored into methods, but that of course would have harmed this work of art.

- The least of the problems, but does anybody know what a pflohneos, a finach or a fidel is? Those are just some of the variable names and they don't make any sense in any language I know.

Edit: Here a tiny sample cut out of the spaghetti monster. It's easy to see what he tries to do, but I can only guess what the intentions behind all this are. There are no comments and the strange variable names don't help very much:
try
{
    string pflohneos = pfl.Name.ToUpper().Replace(pflnamen, "");
    string danapfl = Path.Combine(Konstanten.Flashdir, pflohneos);
    MessageLabel.Text = String.Format(tt.Readwert("t1"), danapfl);
    Refresh();
    try
    {
        FileInfo finach = new FileInfo(danapfl);
        if (finach != null)
        {
            finach.Attributes &= ~FileAttributes.ReadOnly;
        }
    }
    catch
    {
    }
    pfl.Attributes &= ~FileAttributes.ReadOnly;
    pfl.CopyTo(danapfl, true);
    pfl.Delete();
}
catch
{
}


This is really an insult to the customer. Good that they will never get to see this mess in all its glory. My recommendation is to quickly write another application and then tar and feather the guy who wrote this one.
At least artificial intelligence already is superior to natural stupidity



JokeRe: See the writing on the wall... Pin
kdgupta872-May-12 23:32
kdgupta872-May-12 23:32 
GeneralRe: See the writing on the wall... Pin
CDP18022-May-12 23:56
CDP18022-May-12 23:56 
GeneralRe: See the writing on the wall... Pin
Jeremy Hutchinson4-May-12 1:29
professionalJeremy Hutchinson4-May-12 1:29 
GeneralRe: See the writing on the wall... PinPopular
Jörgen Andersson3-May-12 0:00
professionalJörgen Andersson3-May-12 0:00 
GeneralRe: See the writing on the wall... PinPopular
CDP18023-May-12 0:17
CDP18023-May-12 0:17 
GeneralRe: See the writing on the wall... Pin
Jörgen Andersson3-May-12 0:59
professionalJörgen Andersson3-May-12 0:59 
GeneralRe: See the writing on the wall... Pin
CDP18023-May-12 2:34
CDP18023-May-12 2:34 
GeneralRe: See the writing on the wall... Pin
MythicalMe11-May-12 4:59
MythicalMe11-May-12 4:59 
GeneralRe: See the writing on the wall... Pin
Jörgen Andersson11-May-12 8:28
professionalJörgen Andersson11-May-12 8:28 
GeneralRe: See the writing on the wall... Pin
Florin Jurcovici5-Jun-12 23:02
Florin Jurcovici5-Jun-12 23:02 
GeneralRe: See the writing on the wall... Pin
Jörgen Andersson6-Jun-12 1:05
professionalJörgen Andersson6-Jun-12 1:05 
GeneralRe: See the writing on the wall... Pin
BrainiacV4-May-12 3:59
BrainiacV4-May-12 3:59 
GeneralRe: See the writing on the wall... Pin
Bruce Patin7-May-12 6:00
Bruce Patin7-May-12 6:00 
GeneralRe: See the writing on the wall... Pin
BillW333-May-12 0:40
professionalBillW333-May-12 0:40 
GeneralRe: See the writing on the wall... Pin
CDP18023-May-12 0:49
CDP18023-May-12 0:49 
GeneralRe: See the writing on the wall... Pin
BillW333-May-12 3:00
professionalBillW333-May-12 3:00 
GeneralRe: See the writing on the wall... Pin
Florin Jurcovici5-Jun-12 23:05
Florin Jurcovici5-Jun-12 23:05 

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.