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
  • What you say is what you code

    10
    0 Votes
    10 Posts
    119 Views
    R
    hence the full stop at the end of the sentence not a colon. I should check english syntax aswell as code. Thanks for the response. Russ
  • if bool

    13
    0 Votes
    13 Posts
    141 Views
    J
    I do that all the time when I debug and test extreme cases which are hard to simulate using input. I wouldn't want to be caught forgetting about them though. :) -- For proper viewing, take red pill now
  • It always worked well before so leave it like that... [modified]

    13
    0 Votes
    13 Posts
    173 Views
    V
    well, it did not take me even a minute to spot that. i caught the error as soon as i read that there was an error in the code. :) Regards, Vijay. God may not give us what we 'want', but he surely gives us what we 'need'.
  • the hard way

    14
    0 Votes
    14 Posts
    156 Views
    S
    Rob Caldecott wrote: There is a good overview of this on the C++ FAQ: http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.13\[^\] Heh... sure 'nuff. :) ---- ...the wind blows over it and it is gone, and its place remembers it no more...
  • You cannot have it!

    c++
    9
    0 Votes
    9 Posts
    108 Views
    M
    That is very dumb! Unless they use the password as PK, but then again, that would be dumb as well. www.code.ae
  • .NET Framework? What .NET Framework?

    csharp dotnet question
    5
    0 Votes
    5 Posts
    58 Views
    E
    Ooo I feel special :cool:
  • I *suppose* that's a way of determining read permissions..

    5
    0 Votes
    5 Posts
    65 Views
    E
    Brilliant! I'll give this to my colleague to break his head over ;)
  • Two disconnected systems apparently communicating [modified]

    help discussion
    9
    0 Votes
    9 Posts
    85 Views
    P
    If only ADD was a factor in the implementation. There was a long winded "explanation" of why the code was implemented that way that contained "and, besides that situation will never happen." As all good programmers know, if there is even a remotely possible path to a problem, it will occur. Its only a matter of time. Phil
  • if something then... nothing

    com sales
    2
    0 Votes
    2 Posts
    38 Views
    J
    Hmmm! :doh: I have done that when outlining the code before filling the in-betweens. The real question is: what was supposed to be inserted there? INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
  • Infinite for loops

    help c++
    6
    0 Votes
    6 Posts
    67 Views
    J
    That is an excellent paper! I rarely use goto, but sometimes it is the best solution to a problem. (Example: escaping from multiple nested loops.) I once read someone’s general rule that you always go forward, but I found one exception years ago: NEXT_BYTE: if( x>xmin ) { Byte = *(--vptr); /* Skip whole bytes */ if( Byte == 0xFF ) { x -= 8; goto NEXT_BYTE; } } Sure the above code could be written using a loop and originally was, but this increased the speed (graphics code) enough to justify its use at the time. INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
  • We always use "i" as a loop counter...

    c++
    5
    0 Votes
    5 Posts
    47 Views
    J
    Hal Angseesing wrote: ...so lets make it global. :wtf: I am cringing at the very thought of that! :laugh: The largest application (written in C) I ever worked on had more global variables than I bothered to count. I was not allowed to create the original but I was the one who had to fix it for release to the public. When I examined the original code, for the first time, I found a dozen ways to crash the system within 15 minutes of opening the sources files, what a mess. :omg: Do not worry! The finished product worked just as required and would no longer crash the system if looked at it wrong. ;) INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
  • Outrageous error messages

    help hardware learning
    7
    0 Votes
    7 Posts
    73 Views
    E
    I found a TODO: handle string thingie in some code the other day..until today I STILL don't know what the author ment to say :sigh: To reassure you, I long promoted that function to the recycle bin.
  • Remember - this is supposed to be C#...

    csharp performance help question discussion
    3
    0 Votes
    3 Posts
    42 Views
    E
    My colleague and I had an interesting discussion about this. According to us, there are two types of programmers out there. The first type thinks 'This is such a common thing to do, someone MUST have included it' and therefor ends up using the PadString method. The second type just churns away without seconds thoughts and ends up with the originally posted code. The funny thing is that 9 out of 10 times people tend to refactor these snippits into a utilities class, calling the method 'PadString' :cool:
  • Nice catch!

    debugging question
    18
    0 Votes
    18 Posts
    217 Views
    E
    JohnnySacks wrote: Besides, 'some day' we're going to integrate an error capture and/or logging methodology into this business critical high visibility application which re-engineers our business case to leverage best-practice synergies to pro actively actualize our bottom line but at this point we really don't know what features are required and we're REALLY in a hurry to get something done so for now, we'll just put the blocks in place and fill them in later. This sounds so scarily like my manager..no wonder we've decided not to listen to him anymore ;P
  • Oracle stored procs

    csharp oracle
    2
    0 Votes
    2 Posts
    28 Views
    P
    Old habits die hard. It reminds me of: At a job I had ten years ago, we were just switching from Oracle using PRO*C to Sql Server (6 I think) using ODBC. No one in the company knew anything about ODBC so a "consultant" was brought in and, as the story went, given two days to write us a library of functions we could use. What he did, as the story continued, was copy examples from the floppy that came with an ODBC book. The functions returned the values as CSV strings! Management thought this was a perfectly usable solution. When I started using it after others had been for six months or so I said something that can't be repeated in the Lounge. There was absolutely no way I was going to stand for it, but I didn't have much time to fix it, so I made it only marginally better... my versions of the functions returned the values as arrays of strings. I left the company soon after, but had I stayed I was to be tasked with completely rewriting the library, I wish I had. --| "Every tool is a hammer." |--
  • Bit operations in VBScript

    c++ com architecture
    5
    0 Votes
    5 Posts
    47 Views
    L
    "pointer = null; pointer = null;"? Well... very interesting. However, I suppose it doesn't make the problem solved. I would rather use: "while (pointer != null) pointer = null;"
  • The daily WTF!

    com
    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • Dastardly use of ComboBox

    csharp php wpf winforms com
    7
    0 Votes
    7 Posts
    80 Views
    B
    Sob! However, if we're talking about pure ASP, in high school I just used sessions to grant persistency between pages. Dunno if this can be done in .NET, i'm not into it ;)
  • duplicate variable names seperated by scope

    com regex help
    2
    0 Votes
    2 Posts
    30 Views
    B
    Makes me remind of the last programming exams i took... They make you go insane with a snippet 10 times difficult than the above, then they ask you "WTF does var on line x refer to, which is its value?" Someone just never learns ;)
  • VB.NET -> C# ?

    csharp c++ com architecture
    16
    0 Votes
    16 Posts
    168 Views
    J
    Pascal Ganaye wrote: C++ is heaven and VB.Net is hell VB.NET might be hell - I can't comment on that. But C++ is certainly not heaven. Its more like the treadmill of everyday life: Somtimes fun and really exiting, somtimes making you mad, but most of the time just plain boring and repetitive. Failure is not an option - it's built right in.