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
  • Its always good to check for nothing.....

    26
    0 Votes
    26 Posts
    0 Views
    B
    People were paid to make my compiler do that. And it does.
  • When the comment is longer than the code

    csharp database linq algorithms learning
    7
    0 Votes
    7 Posts
    0 Views
    M
    I write comments like that too, especially if I have to do something that isn't obvious as to WHY I'm doing it. (Usually because the client is asking for something that's just the opposite of what they wanted six months ago.) It also lets other people know to think twice before changing that code willy-nilly.
  • Debugging pain

    csharp asp-net com performance help
    4
    0 Votes
    4 Posts
    0 Views
    M
    We have an application that automates the running of other applications we have that take data feeds from clients and process them. Automation uses a command line to kick of the different processing programs. All of the sudden the automation starts logging an error even though the processing completes successfully. I finally track down the location of the line that is recording the log message. The code in automation scans the log file of the processing program for the string "error" and reports if it finds it. I look through the log files of the processing programs and everything looks normal, no errors being reported. After several more reports of this problem I am looking at the log file again and I finally find the cause of the problem. The file services people who manage the automation process wanted more detailed logging, to include recording the command line parameters being used for each different run of the processing application. One of those command line parameters is used to turn on and off message/error logging. The message sent to the log file for the logging switch said, "Command Line Parameter to log errors" WHOOPS! :-O Yes, I added that code.
  • Sometimes, I'm too clever for my own good...

    database csharp linq help question
    12
    0 Votes
    12 Posts
    0 Views
    C
    OriginalGriff wrote: Pre-PC technology indeed, FTFY :rolleyes: »»» Loading Signature ««« · · · Please Wait · · ·    :badger:   :badger:   :badger:
  • System.Data.IDataParameterCollection.Item

    csharp
    5
    0 Votes
    5 Posts
    0 Views
    P
    Yes, but they didn't add a generic alternative to the collection so I still have to cast even today. You'll never get very far if all you do is follow instructions.
  • Why do I bother?

    question database com design help
    27
    0 Votes
    27 Posts
    2 Views
    N
    Surely it should be: string checkuser = " select count(*) from UserDetail where UserName=@UserName"; SqlCommand com = new SqlCommand(checkuser, conn); com.Parameters.AddWithValue("@UserName", TextBoxUN.Text); Web | News | LinkedIn
  • Expression containment field...

    7
    0 Votes
    7 Posts
    0 Views
    R
    I think they got arrested by the bad hair squad.. Bad Hair Day[^] "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
  • Farts are good for you.

    com announcement
    3
    0 Votes
    3 Posts
    0 Views
    R
    Personally, I prefer women who don't fart, but vive la difference. "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
  • Question of the year

    tools question
    11
    0 Votes
    11 Posts
    0 Views
    F
    Quote: :doh: :sigh: :WTF: :( :(( :sigh: My sentiment, precisely! - I would love to change the world, but they won’t give me the source code.
  • One way to slice a pie

    announcement
    8
    0 Votes
    8 Posts
    0 Views
    G
    While PI = math.asin(1) * 2 may be mathematically correct, it's probably not the most accurate representation of π you could create. It depends upon the arcsine function implementation. You might get lucky in case they shortcut the value for an argument of 1, and simply return the library's value of π. If not, they're going to do the arcsine calculation using a numerical method that will approximate something close to π. In other words, it would be more precise if the library simply gave you its value of π. For casual calculations, the difference may not matter. If you're doing a simulation, having your value of π off by a couple bits could have long-term consequences. Software Zen: delete this;
  • Not the best example in the book

    question learning sysadmin tutorial announcement
    6
    0 Votes
    6 Posts
    0 Views
    M
    This does not generate UNIQUE ids, only RANDOM ids. There is nothing preventing the generation of an id that has been previously generated. If you want unique ids, use Guids. String id = Guid.NewGuid().ToString();
  • Comparisons...

    career
    5
    0 Votes
    5 Posts
    0 Views
    J
    Ha! I found the problem. DAX uses a caching mechanism to avoid too many roundtrips to the SQL Server. If you're using the primary key in a query, then DAX will search an in-memory cache to retrieve a single record. Apparently, DAX gets confused when I use the primary key field busRelAccount on the left hand side of the comparison. Using bus.disableCache(true) fixes this problem. I hope they get rid of this bug soon, I really don't like to think of all the places I could have trusted this to just work. "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
  • Uncheck this if you are not a bot

    13
    0 Votes
    13 Posts
    0 Views
    OriginalGriffO
    I've seen that with "Kittens" and "Puppies" as well - very damn annoying! Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
  • IIF to the rescue...

    help
    13
    0 Votes
    13 Posts
    0 Views
    J
    The second one would be: Return (Ordernumber = 0) <edit>Or like this: Return 0 = Ordernumber </edit> Wrong is evil and must be defeated. - Jeff Ello[^]
  • XPath oddity

    xml learning
    3
    0 Votes
    3 Posts
    0 Views
    P
    Thanks, I'll try that too and maybe do some performance comparisons. Performance really isn't an issue with my current usage -- about forty elements being checked with a predicate provided on the command-line. Your second implementation might make for the basis of an enumerator. :thumbsup: You'll never get very far if all you do is follow instructions.
  • FacePalm

    database sharepoint announcement
    4
    0 Votes
    4 Posts
    0 Views
    B
    Ah. I see. What do you get when you cross a joke with a rhetorical question?
  • Starting to page OS to disk!

    visual-studio learning csharp com debugging
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Checking for empty guid

    20
    0 Votes
    20 Posts
    0 Views
    P
    Bernhard Hiller wrote: it returns a *special* list for Guid.Empty()! It's _expecte_d to, but does it? You'll never get very far if all you do is follow instructions.
  • I had a cup of coffee today

    3
    0 Votes
    3 Posts
    0 Views
    A
    He turned it into poo. Don't comment your code - it was hard to write, it should be hard to read!
  • Interesting technique used in some Legacy code!

    26
    0 Votes
    26 Posts
    5 Views
    S
    Much better way of defining maybe, love it! :-D My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!