Skip to content

The Weird and The Wonderful

It was the best of code, it was the worst of code. Coding Horrors, Worst Practices, and flashes of brilliance

This category can be followed from the open social web via the handle the-weird-and-the-wonderful@forum.codeproject.com

1.8k Topics 20.7k Posts
  • Why?

    com question
    12
    0 Votes
    12 Posts
    0 Views
    A
    That is exactly correct! :thumbsup: Thou mewling ill-breeding pignut!
  • China wholesale TaylorMade Putter

    html com business help
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • What the hell is wrong with people today?

    database mysql oracle debugging question
    3
    0 Votes
    3 Posts
    0 Views
    A
    :laugh: :thumbsup: Full-fledged Java/.NET lover, full-fledged PHP hater. Full-fledged Google/Microsoft lover, full-fledged Apple hater. Full-fledged Skype lover, full-fledged YM hater.
  • Contact Us - here, have our email addresses

    com beta-testing question code-review
    10
    0 Votes
    10 Posts
    0 Views
    enhzflepE
    :-D Nope, not intended - a total :doh: moment. Did get an interesting spam from a 'hong-kong bank' in the period though. Well worth the :laugh: Make it work. Then do it better - Andrei Straut
  • Security - You're doing it wrong!

    security csharp java php com
    8
    0 Votes
    8 Posts
    0 Views
    E
    Andrei Straut wrote: On the other hand, I'm having fun now with LINQ parsing the list of products from suppliers (didn't get to play with LINQ so far, but I'm quite liking it. Heard it's pretty slow compared to the other alternatives, but in my case speed is not that much of an issue) One thing that can make LINQ slow is not caching query results appropriately. (Not saying it's not slow to begin with; I really don't know!) For instance: // this method is very slow, it uses the database and network and maybe the TARDIS too public IEnumerable GetLotsOfData() {...} // this method is *extremely* slow since it calls the database and network over and over again public void CrashYourServer() { var data = GetLotsOfData(); // this just saves a QUERY! not the data! // so far so good... foreach (var item in data) { item.DoFancyBusinessOperation(); } // wait, iterating over the enumerable again? uh-oh! foreach (var item in data) // going to call the database and network and TARDIS again! { item.DoOtherFancyBusinessOperation(); foreach (var otherItem in data) // what, now we need an O(N^2) operation? NOOOOOO! { ComparisonResults.Add(item.CompareTo(otherItem)); } } } // this method is more efficient! public void PlayNice() { var data = GetLotsOfData().ToArray(); // this actually loads and caches the data, yay! foreach (var item in data) { item.DoFancyBusinessOperation(); } foreach (var item in data) { item.DoOtherFancyBusinessOperation(); foreach (var otherItem in data) { ComparisonResults.Add(item.CompareTo(otherItem)); } } }
  • Ran across my old code... Must have been tired...

    4
    0 Votes
    4 Posts
    0 Views
    E
    And I thought the WTF was a "maximum" function which takes a string and an int, until I saw the comment...
  • A MySQL horror

    mysql help
    13
    0 Votes
    13 Posts
    0 Views
    E
    We have (for many years now) a worse problem in Or-ache-le. A query should return 3000 rows. It just returns 1200 and does not generate any error. A corrupted value in a key terminated the retrieval, but it still returned success.
  • Admin Scripts

    question
    7
    0 Votes
    7 Posts
    0 Views
    K
    Is this for real?? I hope I have not become rusty on my Perl skills, as I am unable to comprehend how this ever works out --> Getting information off the Internet is like taking a drink from a fire hydrant. --> In three words I can sum up everything I've learned about life: it goes on.
  • iScreen = iScreen < 8 ? iScream : ...

    question
    14
    0 Votes
    14 Posts
    0 Views
    B
    :eek: Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]
  • The worst way to name a variable

    lounge
    8
    0 Votes
    8 Posts
    0 Views
    B
    I know a kid who names his variables x, xx, xxx, xxxx, and so on and so forth. His methods have names like "JDOEHSNFD" (Note all caps). The professor was not very happy when trying to read (and grade) his code. The student also did things like 'String xxx = "879374930";' and then the next line would be 'int xxxx = Integer.parse(xxx).intValue();' The string variable would not be referenced AT ALL after that! Is it any wonder he failed? Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]
  • Alcatraz ~ the tourist website

    com question
    16
    0 Votes
    16 Posts
    0 Views
    B
    :doh: :wtf: :omg: :~ :sigh: :(( Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]
  • ConvertToReadableNumber

    question career
    13
    0 Votes
    13 Posts
    4 Views
    A
    Agreed, clearly the assumption here is that a decimal number is not readable :)
  • Microsoft.Sharepoint.dll

    csharp sharepoint com tutorial question
    6
    0 Votes
    6 Posts
    1 Views
    L
    They obviously don't realize an 'axe-murderer' is maintaining/using their code ;p IronScheme ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))
  • :'-(

    database com help workspace
    35
    0 Votes
    35 Posts
    2 Views
    W
    I think you hit the nail on the head, reading is key but application is more important. I seem to have a hard time adapting what I am reading unless it is blindingly obvious. What are the sites with programming puzzles that you are referring to. I have been writing code for almost 17 years now in various languages and platforms but I discovered Patterns just months ago (though I suspected their existence for years)and I am slowly realizing that the vast majority of my applications were a horrible implementation of MVC and Active Record patterns. I think I am a voracious reader but in the past I did not want to read anything related to programming or design but I am trying to change that. A good mentor seems to be extremely hard to find . Again thanks for your time
  • Socking but funny..!!

    csharp java visual-studio com question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • And this is why I hate PHP (again)

    help php html oracle business
    28
    0 Votes
    28 Posts
    1 Views
    B
    Did you read the subthread? I already linked to the manual page about double quoted strings (the context we're talking about here) where that's not true.
  • What's the f()?!

    csharp ruby question
    6
    0 Votes
    6 Posts
    0 Views
    P
    What do you mean by "C# wouldn't allow abuse of the comma operator"? C# doesn't have a comma operator. A quick search pulled up this little gem (I wonder how it got copied from the MSDN foum :sigh: ): http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-csharp/93126/C-for-loop-and-comma-operator[^] Yes, that's a horror -- the method should have a better name and it could even be made generic! public T LastOf ( params object[] list ) { return ( (T) list [ list.Count - 1 ] ) ; } It's still silly, but this just points up how easy it is to implement a way to get around the limitation. Come to think of it, couldn't you do it with Linq? I don't know Linq, but something like: (new int[] { a++ , b++ }).Last ? P.S. Here's a little test of the concept: int i = 0 ; int j = 0 ; while ( (new int\[\] { i++ , j += 2 }).Last() < 10 ) { System.Console.WriteLine ( "{0} {1}" , i , j ) ; } for ( i = 0 , j = 0 ; (new int\[\] { i++ , j += 2 }).Last() < 10 ; ) { System.Console.WriteLine ( "{0} {1}" , i , j ) ; }
  • Bang Head!

    wpf com architecture workspace
    5
    0 Votes
    5 Posts
    1 Views
    B
    ExcellentOrg wrote: DLL Hell Well, that works as well! Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]
  • I don't got time for no stinking opera!

    javascript ruby debugging question
    12
    0 Votes
    12 Posts
    0 Views
    B
    What hasn't Opera screwed up? Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions. Dave Barry Read more at [BrainyQuote](http://www.brainyquote.com/quotes/topics topic_technology.html#yAfSEbrfumitrteO.99)[^]
  • 0 Votes
    8 Posts
    4 Views
    OriginalGriffO
    I've done it myself from time to time... :-O Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water