Click here to Skip to main content
15,901,001 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: Need to vent... Pin
Timothy Byrd30-Dec-08 10:47
Timothy Byrd30-Dec-08 10:47 
GeneralRe: Need to vent... Pin
Chris Meech30-Dec-08 9:45
Chris Meech30-Dec-08 9:45 
GeneralRe: Need to vent... Pin
Deflinek30-Dec-08 20:45
Deflinek30-Dec-08 20:45 
GeneralRe: Need to vent... PinPopular
kenrentz31-Dec-08 6:06
kenrentz31-Dec-08 6:06 
GeneralRe: Need to vent... Pin
supercat94-Jan-09 8:39
supercat94-Jan-09 8:39 
GeneralRe: Need to vent... Pin
ToddHileHoffer5-Jan-09 7:04
ToddHileHoffer5-Jan-09 7:04 
GeneralRe: Need to vent... Pin
Douglas Dean7-Jan-09 4:52
Douglas Dean7-Jan-09 4:52 
GeneralRe: Need to vent... Pin
Megidolaon23-Feb-09 23:20
Megidolaon23-Feb-09 23:20 
What is the point of
if (node.Attributes["Publish"].InnerText.Trim().Contains(s))
                {
                    return;
                }
A check for containting a single letter and then doing nothing?

Also,
public static ArrayList NonTranslatable
        {
            get
            {
                nonTranslatable.Add("1st String");
                nonTranslatable.Add("2nd String");
                // ...
                nonTranslatable.Add("30th String");
                return nonTranslatable;
            }
        }
Sorry, but WTF is this ****?
Who the hell adds elements to a collection in the getter?
And where do the strings come from?
From a DB? When are they checked? When is determined if something is non-translatable?

foreach (DictionaryEntry de in translationDictionary)
            {
                if (de.Key.ToString().Equals(node.Attributes["Publish"].InnerText.Trim()))
                    node.Attributes["Publish"].InnerText
                            = translationDictionary[node.Attributes["Publish"].InnerText.Trim()].ToString();
            }

I never used a SortedList, you can access its elements with the DictionaryEntry class, is there any difference to a dictionary?

Timothy Byrd wrote:
Simply putting an if (nonTranslatable.Count == 0) block around the code in the NonTranslatable property took the run time down from >75 minutes to ~30 seconds. (Fun fact: During the 75 minutes of processing, those repeated Add() calls caused the program to take up about 25MB of extra memory. That's a lot of strings to loop through and compare repeatedly. OMG )

Wow.

Timothy Byrd wrote:
Not to mention all the calls to Trim() inside the loop. Or does the runtime optimize those out as invariant?

Maybe the XML contains trailing spaces?
Unless you trim them, the XML Nodes' InnerText wouldn't equal the DictionaryEntries with same key.

Anyway, I feel truly sorry for you... Dead | X|
GeneralRe: Need to vent... Pin
Timothy Byrd24-Feb-09 8:18
Timothy Byrd24-Feb-09 8:18 
Rantgreat way to clear asp.net form fields Pin
freddy rios29-Dec-08 15:05
freddy rios29-Dec-08 15:05 
GeneralGood if paid by number of lines! Pin
Asad Abbasi29-Dec-08 5:11
Asad Abbasi29-Dec-08 5:11 
GeneralRe: Good if paid by number of lines! [modified] Pin
PIEBALDconsult29-Dec-08 5:41
mvePIEBALDconsult29-Dec-08 5:41 
GeneralRe: Good if paid by number of lines! Pin
hammerstein0529-Dec-08 6:28
hammerstein0529-Dec-08 6:28 
GeneralRe: Good if paid by number of lines! Pin
singh.iz.king29-Dec-08 13:34
singh.iz.king29-Dec-08 13:34 
GeneralRe: Good if paid by number of lines! Pin
Megidolaon22-Feb-09 23:21
Megidolaon22-Feb-09 23:21 
GeneralRe: Good if paid by number of lines! Pin
Luc Pattyn29-Dec-08 16:13
sitebuilderLuc Pattyn29-Dec-08 16:13 
GeneralRe: Good if paid by number of lines! Pin
LarryDM1-Jan-09 22:31
LarryDM1-Jan-09 22:31 
GeneralDevil's advocate Pin
supercat94-Jan-09 8:29
supercat94-Jan-09 8:29 
GeneralRe: Good if paid by number of lines! Pin
Rauhotz14-Jan-09 12:55
Rauhotz14-Jan-09 12:55 
GeneralRe: Good if paid by number of lines! Pin
itsravie3-Mar-09 3:18
itsravie3-Mar-09 3:18 
GeneralRe: Good if paid by number of lines! Pin
Divyang Mithaiwala3-Apr-09 23:24
Divyang Mithaiwala3-Apr-09 23:24 
GeneralMaking shortcuts even shorter Pin
gnjunge26-Dec-08 4:45
gnjunge26-Dec-08 4:45 
GeneralRe: Making shortcuts even shorter Pin
Sauce!27-Dec-08 18:04
Sauce!27-Dec-08 18:04 
GeneralRe: Making shortcuts even shorter Pin
gnjunge27-Dec-08 20:56
gnjunge27-Dec-08 20:56 
GeneralRe: Making shortcuts even shorter Pin
Tony Pottier27-Dec-08 23:52
Tony Pottier27-Dec-08 23:52 

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.