Click here to Skip to main content
15,902,635 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: Magic of if...else...programming PinPopular
Tony Pottier10-Jan-09 8:52
Tony Pottier10-Jan-09 8:52 
GeneralRe: Magic of if...else...programming Pin
vnike16-Jan-09 2:53
vnike16-Jan-09 2:53 
GeneralRe: Magic of if...else...programming Pin
S. Senthil Kumar17-Jan-09 9:10
S. Senthil Kumar17-Jan-09 9:10 
GeneralNeed to vent... Pin
Timothy Byrd30-Dec-08 8:42
Timothy Byrd30-Dec-08 8:42 
GeneralRe: Need to vent... Pin
PIEBALDconsult30-Dec-08 9:15
mvePIEBALDconsult30-Dec-08 9:15 
GeneralRe: Need to vent... Pin
GibbleCH30-Dec-08 10:19
GibbleCH30-Dec-08 10:19 
GeneralRe: Need to vent... Pin
PIEBALDconsult30-Dec-08 14:02
mvePIEBALDconsult30-Dec-08 14:02 
GeneralRe: Need to vent... Pin
Timothy Byrd30-Dec-08 10:47
Timothy Byrd30-Dec-08 10:47 
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 | :OMG: )

PIEBALDconsult wrote:
And how about removing the .ToString and .Equals ?


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

I ended up just dumping all their code and using my own. To add another wrinkle they wrote it in VS 2008, and we are still on 2005 until we get this release out, so I couldn't even build their solution.

Besides there were some other issues. Not only was it still 10x slower than my rewrite, but the output wasn't quite correct. The problem is that there was also a non-XML text file that needed to be parsed - imagine taking a Windows .rc file and extracting all the strings that can be translated from it and putting them into an Excel file. They weren't being careful enough with their regular expressions, so some things were getting missed and some extra things were being found.

Using .net 2.0 and a Dictionary<string,> worked fine for me. By making the regular expressions more correct, I didn't need the NonTranslatable array at all. (The two loops I showed were actually in two separate routines, but I wanted to keep my post relatively compact.)

I've vented - I feel better now.

-- T
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 
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 

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.