- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Its nice to see a real coding WTF for a change.
Admin
First of all your hypothetical requirements conflict one another: "bullet proof" and "less than one hour". Nope, sorry, doing it right takes time. This solution is still far too easy to break.
Second, having a time limit doesn't change the fact that the code is a huge WTF. If we really needed a half-assed solution to this problem written as quickly as possible, a competent programmer could have done so without resorting to such convoluted file operations, and in less time, by simply storing the progress and seeking to it at the beginning of an attempt. Even if there were a bizarre requirement that the lines need to be removed from the file, that operation could also run once at the beginning instead of every iteration. This code is not defensible on any level.
Admin
This reminds me of a program I changed just recently. Before, it ran for 4 to 6 hours (depending on how busy the servers where with other stuff). Now it only takes about 1 hour.
Before, there was stuff like: "Look at one line in the table. Look for a specific value. Is this value bigger than X? If so, update another column. Look at the next line in the table..." Of course, every time the db connection was opened and closed. The table in question contains over 120 million records! Usually took about 2 hours to complete. Now I simply load everything into a DataTable (yes, C# is TRWTF), do a foreach over every row and copy everything back with Bulk Copy. Takes a few seconds.
There was other WTF-y stuff in there, like populating a table and then deleting rows that aren't needed (instead of simply excluding them while populating the table) and then doing an update on the table to fill a different column (instead of simply doing this calculation while populating the table).
Admin
Admin