Click here to Skip to main content
15,884,537 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: Applebee's Website Fail Pin
Sentenryu14-Mar-16 4:08
Sentenryu14-Mar-16 4:08 
GeneralRe: Applebee's Website Fail Pin
Dave Kreskowiak14-Mar-16 4:46
mveDave Kreskowiak14-Mar-16 4:46 
GeneralRe: Applebee's Website Fail Pin
Brisingr Aerowing12-Mar-16 14:57
professionalBrisingr Aerowing12-Mar-16 14:57 
GeneralMessage Closed Pin
12-Mar-16 13:04
professionaljgakenhe12-Mar-16 13:04 
GeneralRe: Applebee's Website Fail Pin
Brisingr Aerowing12-Mar-16 14:54
professionalBrisingr Aerowing12-Mar-16 14:54 
GeneralRe: Applebee's Website Fail Pin
snorkie16-Mar-16 9:48
professionalsnorkie16-Mar-16 9:48 
GeneralRe: Applebee's Website Fail Pin
Rob Grainger26-Mar-16 11:57
Rob Grainger26-Mar-16 11:57 
GeneralDataView.RowFilter considered harmful.. Pin
Sascha Lefèvre11-Mar-16 1:57
professionalSascha Lefèvre11-Mar-16 1:57 
..for performance.

I dug up an ETL-method from my .NET-dark ages because I needed it again and in general it's working fine. Just a bit slow. Because there's a lot of transformational stuff going on I first thought that there's just no way around that and considered implementing a nice progress indication for the user that actually delivers on its "remaining time" estimation.

To be able to identify which "atomic parts" of the transformation require how much time I re-arranged the code so that steps which happened in a nested fashion now execute one after another. And to my surprise the transformation which I suspected to be the most time consuming one wasn't! Instead it was a step inside that one which now revealed its awful performance and on closer inspection it boiled down to using DataView.RowFilter, which, I assume, I used because there was no LINQ at the time and I couldn't be bothered to write some loops, assuming that .RowFilter wouldn't be THAT bad. But it is.

Replacing this:
C#
treeView.RowFilter = String.Format("ParentID={0} AND {1}<>{0}", parentId, idColumnName);
(and the code that relies on it) with this:
C#
Dictionary<int, HashSet<int>> itemsByParentId = treeTable.AsEnumerable()
    .Select(row => new { parentId = row.Field<int>[parentIdColIdx], itemId = row.Field<int>[itemIdColIdx] })
    .Where(x => x.parentId != x.itemId)
    .GroupBy(x => x.parentId)
    .ToDictionary(grp => grp.Key, grp => new HashSet<int>(grp.Select(x => x.itemId)));
(and code that uses it instead) cut down the time for the whole ETL-process from 26 minutes to 2 minutes...
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralLet the user know you care - say something nice Pin
imagiro11-Mar-16 1:28
imagiro11-Mar-16 1:28 
GeneralI was wandering around The Daily WTF and.. Pin
Brisingr Aerowing9-Mar-16 20:14
professionalBrisingr Aerowing9-Mar-16 20:14 
GeneralRe: I was wandering around The Daily WTF and.. Pin
Rob Grainger11-Mar-16 3:56
Rob Grainger11-Mar-16 3:56 
GeneralRe: I was wandering around The Daily WTF and.. Pin
Sentenryu14-Mar-16 3:54
Sentenryu14-Mar-16 3:54 
GeneralBest web site design app? Pin
VE29-Mar-16 14:09
VE29-Mar-16 14:09 
GeneralRe: Best web site design app? Pin
Wonde Tadesse9-Mar-16 14:49
professionalWonde Tadesse9-Mar-16 14:49 
GeneralRe: Best web site design app? Pin
VE29-Mar-16 15:19
VE29-Mar-16 15:19 
GeneralRe: Best web site design app? Pin
Brisingr Aerowing9-Mar-16 15:27
professionalBrisingr Aerowing9-Mar-16 15:27 
GeneralRe: Best web site design app? Pin
jsc4210-Mar-16 6:19
professionaljsc4210-Mar-16 6:19 
GeneralRe: Best web site design app? Pin
KarstenK9-Mar-16 20:07
mveKarstenK9-Mar-16 20:07 
GeneralRe: Best web site design app? Pin
effayqueue11-Mar-16 23:23
effayqueue11-Mar-16 23:23 
GeneralProduction reports from a test database - is this really best practice? Pin
johnsyd7-Mar-16 21:33
johnsyd7-Mar-16 21:33 
GeneralRe: Production reports from a test database - is this really best practice? Pin
dan!sh 7-Mar-16 21:44
professional dan!sh 7-Mar-16 21:44 
GeneralRe: Production reports from a test database - is this really best practice? Pin
johnsyd7-Mar-16 21:59
johnsyd7-Mar-16 21:59 
GeneralRe: Production reports from a test database - is this really best practice? Pin
johnsyd7-Mar-16 22:04
johnsyd7-Mar-16 22:04 
GeneralRe: Production reports from a test database - is this really best practice? Pin
dan!sh 7-Mar-16 22:45
professional dan!sh 7-Mar-16 22:45 
GeneralRe: Production reports from a test database - is this really best practice? Pin
Duncan Edwards Jones7-Mar-16 22:02
professionalDuncan Edwards Jones7-Mar-16 22: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.