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
    6 Posts
    2 Views
    A
    I know! Politics! I can't touch it yet :-( Alberto Bar-Noy --------------- “The city’s central computer told you? R2D2, you know better than to trust a strange computer!” (C3PO)
  • Epic method to check if database table contains any suitable rows

    database
    15
    0 Votes
    15 Posts
    2 Views
    J
    Select Count(*) has to do the fuzzy like search on the whole table just to show rows that match might exist - so it will probably do a full table scan (if start of like is a %) better is to let SQL return as soon as it has found one row that matches - so use exists - e.g. String.Format("SELECT 1 WHERE EXISTS (SELECT 1 FROM data WHERE oznacenie LIKE '{0}')", data) That way SQL can stop looking after the first row it finds that matches. Depending on size of table this can make a huge difference in performance. This will return 0 or 1 records to the rowcount which you can get using ExecuteScalar return
  • Perfect way to show a splash screen

    sharepoint
    11
    0 Votes
    11 Posts
    1 Views
    M
    Better one ... :laugh: private static void DoSplash() { Interaction.Shell(Application.StartupPath + "\\splashscreen.exe", AppWinStyle.MaximizedFocus, true, -1) } .. and God help us all ;P
  • Why SQL Server sucked on Friday

    database sysadmin help sql-server security
    4
    0 Votes
    4 Posts
    0 Views
    S
    I'd rather not have them "foc" me in the "uss" and they can keep their dinner. Ego non sum semper iustus tamen Ego sum nunquam nefas!
  • Hopeless cases [modified]

    java
    9
    0 Votes
    9 Posts
    1 Views
    J
    My mouth is just wide open... speechless ________ John Y. Developer
  • Document layout

    2
    0 Votes
    2 Posts
    0 Views
    B
    Yeah, thats an "ARGH!" :sigh: Just because the code works, it doesn't mean that it is good code.
  • This is pretty special.

    php com help
    9
    0 Votes
    9 Posts
    0 Views
    J
    That is a work of art! :laugh: :laugh:
  • Not so much bad code as kludge

    xml question
    4
    0 Votes
    4 Posts
    0 Views
    U
    Also try Application.CutCopyMode = False
  • Shocking.

    php com
    7
    0 Votes
    7 Posts
    0 Views
    S
    Sorry... it is in there for Justin Case ;) (yes|no|maybe)*
  • Immutables and indexers and finalizers, oh my!

    database regex functional
    10
    0 Votes
    10 Posts
    0 Views
    F
    Couldn't you use a delegate here? Pass a delegate for a void function taking an Oblong to ReduceCandidates(). Then you could implement the ReduceCandidates() in the library as a member of OblongCollection and the application specific code inside the delegate definition in the application.
  • Export to Excel

    csharp css com question
    11
    0 Votes
    11 Posts
    0 Views
    S
    Thanks for the tip. Yea.. that project was done in record time about a year ago. But will keep it in mind!
  • True that

    8
    0 Votes
    8 Posts
    0 Views
    I
    I actually have a LOT of While 1=1 in MS SQL... It's very cool, works great, and I just love to see the face of programmers when I show them with pride my nested while 1=1 loops in recursive stored procs... ;P
  • worst error message or best

    regex help
    7
    0 Votes
    7 Posts
    1 Views
    S
    I like that one, actually. The worst error message IMO remains "Abort, Retry, Fail?"
  • Double salvo function

    7
    0 Votes
    7 Posts
    0 Views
    E
    Hmm, that would actually explain the SE5 language, as it does look quite a bit like Pascal... the guy who wrote the game was apparently primarily a Delphi programmer!
  • This is the least of...

    csharp php database winforms com
    15
    0 Votes
    15 Posts
    0 Views
    B
    My current work project (code base from another company) is full of these, though wrapping in custom exception types and preserving the inner exception. It makes sense when you want to add extra semantic information to the exception because you know the context in which it was called. It doesn't the amount they've done it (and it makes tracking down the actual point of failure a pain). It is 'heavy', yes, but of the order of milliseconds, and if you're using exceptions properly (i.e. they are only thrown in exceptional circumstances) that doesn't matter.
  • Error message in software I support...

    help
    12
    0 Votes
    12 Posts
    0 Views
    A
    My favorite all time error message on a program I worked on- "Shut 'er down Clancy, she's pumping mud." shown just before the program crashed. No other information. Good for a laugh, but not much else.
  • I have one that its obvious.

    com help
    7
    0 Votes
    7 Posts
    0 Views
    W
    I mean _absolutely_ nothing, just like the error messages you posted meant nothing. I was just mocking about that "obvious" number; you shouldn't take that seriously. But _if_ I had intended a deeper meaning with the sentence you just quoted, it would be this: There are some people out there who are writing code just like this "obvious error message". When it comes down to maintenance, no one else could handle that kind of bullsh... horse dung. That's active job security, right there! :-\ So, whenever you stumble upon some messages like these, rest assured: There's a dude with a water tight career. He's roared up to a position where his employer is taking crap like that from him, because he couldn't let him go. But that's just a interpretation of what I wrote. Hell, if I know what I was thinking all the time, I would at least be a miner god. Or totally crazy. Better not find out. That seems to be a PEBKAC problem, Sir. Why don't you go and fetch a coffee while I handle the operation?
  • Needed a series of random numbers

    lounge workspace
    15
    0 Votes
    15 Posts
    0 Views
    L
    I think the error was naming the variables as "n", "t" or "i". ;P
  • Converting binary to decimal the hard way

    csharp com question
    6
    0 Votes
    6 Posts
    0 Views
    P
    Probably a ToUpper as well, to protect against lower-case binary digits. :sigh:
  • 21,662

    csharp winforms tools
    18
    0 Votes
    18 Posts
    2 Views
    Sander RosselS
    witm55 wrote: I use to write that the same way I write read/write-Properties. So do I :laugh: Just wanted to say that it is not really very different from a Const in a usage kind of way. I think with todays tools the CAPITOLS_AND_UNDERSCORES is not necessary anymore. Visual Studio IntelliSense gives an icon saying something is a Const, it gives you text saying it is a Const, it gives the same if you hoover over it and with one "go to definition" you can see really everything you want to know about it. But from a historic point of view it is sometimes good to know why certain things are as they are :) It's an OO world. public class Naerling : Lazy<Person>{}