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
  • 0 Votes
    2 Posts
    0 Views
    K
    "[Update: 18 November 2002: Microsoft have announced that a future version of C# will include support for anonymous methods.]" The article must have been written against .net 1.0, when the framework was pretty immature compared to Java. Sort of a cross between Lawrence of Arabia and Dilbert.[^] -Or- A Dead ringer for Kate Winslett[^]
  • Not null check

    announcement
    11
    0 Votes
    11 Posts
    0 Views
    L
    How about overloading those operators? Also, you might want to use the monad- or the decorator pattern to split that up into multiple lines :) I are Troll :suss:
  • Submission for the Guiness book of world records

    question learning
    7
    0 Votes
    7 Posts
    0 Views
    M
    What translation? I have to maintain and fix bugs in his code. It is all like that. Variables have wrong names, and their meaning changes al the time. Variable named "exchange" may actually mean "exchange_code", "exchange_id", "IExchange", "ExchangeConfig". "string exchange" may be used to keep "exchange_id", "exchange_code", and later on "exchange_name"... "instrument" may be of type "IInstrumentWrapper", "Ric", "Occ", "IDataAccessor", or whatever, and "accessor" means exactly the same... What about his unique approach to multi-threading? GUI thread: Click start background thread do something synchronous post to GUI Dispatcher wait until GUI is done do something synchronous post to GUI Dispatcher wait until GUI is done do something synchronous post to GUI Dispatcher wait until GUI is done do something Thread synchronization? Done using bunch of boolean flags, so it is one big race condition waiting to happen. There is no way to stop any background thread of course, so usually you have to use TaskManager to kill the application after you click "Close". Forget about memory leaks and such.
  • IsNullOrEmpty

    csharp html
    16
    0 Votes
    16 Posts
    0 Views
    P
    Yes, but String isn't an IList -- but not to worry, I wrote... I wrote my own String class today. :cool:
  • Coded by an Expectional person

    4
    0 Votes
    4 Posts
    0 Views
    A
    Yeah, I can't get it to throw an exception (even when I use an invalid key), though the MSDN documentation says an exception can be thrown. One more thing I noticed is that ConfigurationSettings.AppSettings is deprecated in favor of ConfigurationManager.AppSettings, though it may be fine if the code resides in an older version of the .Net Framework in which that was not yet deprecated. [WikiLeaks Cablegate Cables]
  • 0 Votes
    4 Posts
    0 Views
    D
    Kinda learned that one, didn't I? :P Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
  • What a fright!!

    regex question discussion
    4
    0 Votes
    4 Posts
    0 Views
    D
    Throw new UserFellAsleepAtTheKeyboardException(me) Dwayne J. Baldwin
  • Useless function

    6
    0 Votes
    6 Posts
    0 Views
    M
    Robert Croll wrote: Actually very handy if you are passing a object type which has an underlying value of type bool But this specific function does not take an object. It takes a bool and returns a bool. Just wasted code in any usage return 5;
  • Is this how we deprecate now?

    com question
    5
    0 Votes
    5 Posts
    0 Views
    M
    Hmmm, let's improve it! static void AddEquipment(object dontUseThisWeHaveToDeleteThisMethod) { if (dontUseThisWeHaveToDeleteThisMethod is bool && (bool)dontUseThisWeHaveToDeleteThisMethod) return; } Seems better?
  • It's not the most obvious piece of logic.

    php ruby com tools question
    30
    0 Votes
    30 Posts
    2 Views
    L
    I use less ! on my messenger :laugh: - Bits and Bytes Rules! 10(jk)
  • Recursive methods. [modified]

    docker help question
    5
    0 Votes
    5 Posts
    0 Views
    realJSOPR
    The root of the problem is that it's done in VB... ".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
  • Would you laugh or cry?

    ruby question
    13
    0 Votes
    13 Posts
    2 Views
    R
    LOL it made me laugh enough.
  • Catch an Exception... then throw it?

    csharp question
    26
    0 Votes
    26 Posts
    1 Views
    M
    That's the best answer I have seen yet. sometimes writing code is not about making it work, but how to handle things when they don't work....... :laugh:
  • Testing the obvious....

    testing beta-testing
    12
    0 Votes
    12 Posts
    3 Views
    E
    :laugh: :laugh: :laugh: :laugh: .. ... try { retry: while (filename = EmptyString) { if(Len(fileName) == 0) { fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF" } } } catch { goto retry; } filename = ""; :laugh: :laugh: :laugh: :laugh: :laugh: .... just trying to see how many people will complain about this.... ;P I'd blame it on the Brain farts.. But let's be honest, it really is more like a Methane factory between my ears some days then it is anything else... ----- "The conversations he was having with himself were becoming ominous."-.. On the radio...
  • one indian song for the salary

    csharp javascript asp-net linq com
    9
    0 Votes
    9 Posts
    0 Views
    B
    No more lame than many of the things that have been posted in the Lounge section. My only objection was that it belongs in the General Indian Topics forum or the Lounge forum (with a translation). Just because the code works, it doesn't mean that it is good code.
  • IDataAccessLayer

    learning
    5
    0 Votes
    5 Posts
    1 Views
    P
    Gaaah!!! throw new Stone(); Agh! Reality! My Archnemesis![^] | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy
  • My introduction to "##"

    career hardware question
    24
    0 Votes
    24 Posts
    0 Views
    P
    :laugh: Yeah, maybe. Agh! Reality! My Archnemesis![^] | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy
  • How to get the logged in user

    tutorial
    3
    0 Votes
    3 Posts
    0 Views
    M
    If rewritten properly this method is tail-recursive and thus ipso facto iterative (by nature).
  • Search the causal link between this and devs going mad o_O

    php com help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Implode / Join

    com
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied