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
  • Fun With CString

    regex
    14
    0 Votes
    14 Posts
    10 Views
    J
    What, checking for null is to sophisticated for you? :) Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
  • 0 Votes
    9 Posts
    4 Views
    A
    so, for(int i=0; i<source.length;> { result[i] = source[i]; source[i].~object(); result[i].~object(); } return result; Makes sense to you? I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
  • A Coding Horror from a subcontracted project...

    csharp
    22
    0 Votes
    22 Posts
    15 Views
    R
    I'd like to see some empirical evidence that programmer's from India are worse programmers before a comment like that. Actually, that subcontracted programmers in India are worse than subcontracted programmers generally. (That was meant as a comment to Rob Parker's post) modified on Monday, July 14, 2008 5:54 AM
  • C++ wrappers for C struct api

    question performance c++ json help
    6
    0 Votes
    6 Posts
    3 Views
    J
    Probably the bold text should be in all capital and font size 36! :laugh:
  • 0 Votes
    12 Posts
    13 Views
    G
    Depends on what you mean by a "normal" cast... 1. If you mean a C-style cast (ie: (uint32) <something> ), then my answer would be that the code is C++ and the correct thing to do is to use the new style casts provided by the C++ language. They are there for a good reason. 2. If you mean, why did I not just allow implicit casting to uint32 by the compiler, it's because assigning a double value to an unsigned long produces a warning message ('possible loss of data') depending on the warning level set for the compilation. Since I compile at the higher warning levels and will see the warning, and have a policy of not allowing warnings from my code, I do the explicit cast. The issues I touched on above are very well described and explained at this site: C++ FAQ Lite. This is a great site for beginners and seasoned c++ programmers.
  • This really happened

    csharp sharepoint collaboration question
    7
    0 Votes
    7 Posts
    6 Views
    P
    Zani Jnior wrote: I still don't know what she wanted with Beats me with what she was trying to accomplish :laugh: "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • Once my junior wanted extra perfection!!!!!!

    question
    17
    0 Votes
    17 Posts
    10 Views
    P
    I keep note of this next time your junior developer is up for a performance review :suss: "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • Huh... that's odd...

    17
    0 Votes
    17 Posts
    9 Views
    P
    Hmmm, I always thought it should be along the lines of: private static bool isEven(int i) { return ((i % 1) == 0); } "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • Ugly or a horror?

    question
    10
    0 Votes
    10 Posts
    4 Views
    P
    Nothing too bad there. One of the most "elegant" pieces of code I wrote in college was done after pounding down a fifth of tequila :-\ It was an amazing piece of work that worked very well. "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • 0 Votes
    10 Posts
    7 Views
    P
    Oops... "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • Does this qualify as horror?

    html xml question
    11
    0 Votes
    11 Posts
    9 Views
    P
    Megidolaon wrote: It's quick & dirty but it does it's job and for a single line of XML I think it's ok. That's what I thought until I was passed some text with values that needed to be encoded. Like < and & and even a Ctrl-C :omg: I have since worked up a class to make it easier and hide the details.
  • Clever For-loop

    10
    0 Votes
    10 Posts
    8 Views
    P
    yvind Bratland wrote: We don't work together anymore I bet that's a good thing :-D "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • Another loop bites the dust

    testing beta-testing career
    21
    0 Votes
    21 Posts
    22 Views
    S
    you mean they didn't want 4294967294 copies??? (till it reached zero again) -Spacix All your skynet questions[^] belong to solved I dislike the black-and-white voting system on questions/answers. X|
  • Self Referential Madness

    database xml
    3
    0 Votes
    3 Posts
    4 Views
    L
    I'd just like to say "then don't do it". Remember that cat! Take a chill pill, Daddy-o .\\axxx (That's an 'M')
  • A real gem.

    c++ ruby question
    5
    0 Votes
    5 Posts
    4 Views
    L
    Tom Delany wrote: I still think it would not have killed them to use a few more lines of code and written it a bit less obtusely. Probably. :) xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008)
  • Trimming off a little too much?

    question
    6
    0 Votes
    6 Posts
    5 Views
    C
    PIEBALDconsult wrote: Probably didn't realize he could do ddl_Operator.DataTextField = ("description").ToString() ; or maybe.. ddl_Operator.DataTextField = ("description").ToString().ToString().ToString().ToString().Trim() ; :) -- www.domagoj.net
  • Captain Obvious

    com
    25
    0 Votes
    25 Posts
    21 Views
    M
    It seems assigning the value of an incremented variable to itself overrides the increment operation. If not, it wouldn't actually matter in which order the operations are executed as the result would be the same: increment comes first: i = 0 // i = 0 i++ = 1 // i = 1 i = i // i = 1 result: 1 assignment comes first i = 0 // i = 0 i = i // i = 0 i++ // i = 1 result: 1
  • Stop the madness...

    database xml learning
    8
    0 Votes
    8 Posts
    5 Views
    A
    Sometimes using compound string keys is the only way to maintain data between multiple systems / instances where there is no shared system key (and no reason to force such a situation). That said, you would hope the individual elements which were used to generate the keys are available as individual columns also to give good performance for queries... AJ
  • Horror, or not?

    database question com tools xml
    30
    0 Votes
    30 Posts
    26 Views
    M
    That made my day! :laugh:
  • Studying informatics...

    c++ csharp data-structures tutorial
    13
    0 Votes
    13 Posts
    4 Views
    M
    Heh, I do about the same. Especially since the Microsoft documentation is a bad joke as it doesn't actually contain any more information than the tooltips in VS. And the vast majority of articles on websites like this one or in books, which aren't about the basics of the basics, rely too much on the context. If you want to know more about class x, the articles usually don't provide much information on the general usage and behavior but only in the specific context of the example, which barely ever has the slight similarity to do with what you need it for. Also, the vast majority of all programming exams consist of scribbling on paper. If not, they usually consist of doing a project and sending in the result. Paper is okay, at least if the reviewer isn't too strict. Subtracting too many points for missing semicolons and such is just stupid. Anyway, the topic really belongs here. Sounds like college/University the creator attends teaches a lot of bad practices.