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
  • Wondering

    game-dev help question
    7
    0 Votes
    7 Posts
    37 Views
    P
    I say we go back to the WTF forum. Deja View - the feeling that you've seen this post before. My blog | My articles
  • Constants definitions

    help csharp c++ visual-studio announcement
    9
    0 Votes
    9 Posts
    28 Views
    C
    KarstenK wrote: But using a name like HWND_MAINWINDOW is also Yeah, it looks like someone is defining window's handles. Which I don't get.
  • css disaster

    ruby css architecture
    4
    0 Votes
    4 Posts
    12 Views
    P
    I'm really not sure which is the worst bit - the fact they're using tables or the really dodgy right margin versions. Where's the IE hack version? sdix wrote: I inherited a website project from another agency who got sacked for being very slow They weren't slow. They produced 600MB of CSS file. Deja View - the feeling that you've seen this post before. My blog | My articles
  • The holy comma operator [modified]

    c++ python learning
    14
    0 Votes
    14 Posts
    45 Views
    J
    Of course in C++ the comma operator can be overloaded like most others. So one can make things really interesting.
  • This one made me sigh

    question
    7
    0 Votes
    7 Posts
    36 Views
    P
    PeterTheGreat wrote: compiled a project from our Outsourcing Contrators... That kind of tells something. I'll just keep my Soapbox thoughts about outsourced contractors to myself :rolleyes: "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
  • try-catch Oo [modified]

    help sales question discussion
    14
    0 Votes
    14 Posts
    41 Views
    W
    Actually it's worse, more like On Error Goto ... WarePhreak Programmers are tools to convert caffiene to code.
  • A Well-Documented Piece of....*bleep*

    css help question workspace
    14
    0 Votes
    14 Posts
    25 Views
    N
    Probably PROLOG interpreter for LISP: the reverse would be extremely difficult. A number of these have been made. The best Common LISP implementation around is AllegroCL (still among the most powerful platforms, esp. with its unmatched AllegroCache). AllegroCL has an extension called AllegroPROLOG, which is implemented on top of AllegroCL in such a way that the programmer can mix LISP and PROLOG code freely, while the PROLOG code is compiled into LISP code and integrated properly. Pretty nice for certain applications, notably Artificial Intelligence, for which AllegroCL is probably best. -Nick P.
  • What's the best way to do conditional compile?

    linux help question lounge
    9
    0 Votes
    9 Posts
    30 Views
    N
    The use of good cross-platform libraries and API's helps reduce or prevent much preprocessor ugliness. If you do it like one person said, with a project/program for each platform, you can simplify that by encapsulating core functionality whenever possible for reuse with many platforms. I often do what I can to separate program logic from GUI code, so that I could port the software to many platforms, while leaving the main logic untouched. (Of course, wxWidgets or Qt with ANSI C++ often means I hardly change a thing, but most people aren't using such libraries...) -Nick P.
  • help pls

    algorithms security help
    13
    0 Votes
    13 Posts
    49 Views
    N
    Although I also have a hard time taking this seriously, here goes a shot at a serious answer. Quantum Cryptography usually signifies two things, as far as current tech allows: (1) generating truly random numbers, via Quant. Phys.; (2) sending keys securely, by using quantum physics to recognize a tap on the line. MagiQ sells VPN hardware that does both of these things. Their RNG alone creates up to 100 unpredictable keys a second. So, what do you need to do? Get some of that hardware. Write VB wrappers around all pertinent API functions. Generate keys with the Quantum RNG, and use them with a good encryption algorithm, like AES. If you are transmitting data, send it using Public Key cryptography, with at least the private keys generated from the quantum hardware. You can do the key-exchange part over quantum hardware, to detect taps. Operator should be notified if line is breached regularly. Just be sure to ask MagiQ (or the other unknown one) for technical documentation, to be sure this would work. Oh yeah, if you build a VB Quantum CryptoAPI, I will be expecting a free copy. :) -Nick P.
  • Rotation [modified]

    6
    0 Votes
    6 Posts
    25 Views
    C
    Then any good runtime will return an error stating quite plainly that: "Sorry. This method is busy. Please call again later." Ninja (the Nerd) Confused? You will be...
  • My sides - they split!

    database sql-server design sysadmin
    9
    0 Votes
    9 Posts
    35 Views
    J
    Good catch - or the Java guy claiming 15 years :) ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog
  • Give me a gun pliz

    question
    8
    0 Votes
    8 Posts
    39 Views
    V
    Impeccable, Unfailing, Trusted Upgradepath for VB. :) Vasudevan Deepak Kumar Personal Homepage Tech Gossips A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
  • switch statement

    12
    0 Votes
    12 Posts
    36 Views
    T
    xenonysf wrote: You should construct a data structure and keep the possible values in case statements in an ordered way in your data structure; then your incoming value should be compared with the values inside your data structure in binary search fashion... this will be faster and save you from time consuming sequential searchin I agree with what you say but not for the reasons you give. A switch/case statement has better performance than a sequence of if/else statements. The compiler may generate a jump table. For large tables, some use binary searches. See http://www.eventhelix.com/RealtimeMantra/Basics/CToAssemblyTranslation3.htm[^]. So performance isn't the driving factor here. But I do agree that the cases -- where possible -- should be encapsulated in a data structure. We would like to have actions for the various cases in a data structure to simply the logic. Complexity leads to increased probability of error. We have unneccessary complexity. However, it takes a while to untangle code that has grown for decades.
  • Assignment [modified]

    7
    0 Votes
    7 Posts
    29 Views
    T
    Uhh....loooks like you've forgotten 1 extra for NUL terminated char... text = (char*)malloc(sizeof(char) * (seven + 1)); And also...check for NULL if this fails...my c skills are a bit rusty so excuse if I trip up, from what I can remember this nice terse statement which was favourite of mine.. if (!(text = (char*)malloc(sizeof(char) * (seven+1)))){ ...mem is gud... }else{ ...phffft... } this is a nice lil exercise since I used to program in C professionally, then switched over to C# cos the skillset was dwindling in the IT sector here in Ireland... not sure why you'd free the pointer though...I think that you'll have garbage in text_store.title...I could be way off here on this... Take care, Tom #define STOOPID #if STOOPID Console.WriteLine("I'm stoopid!"); #endif
  • How many things are wrong with this code? [modified]

    java question
    7
    0 Votes
    7 Posts
    33 Views
    J
    Vasudevan Deepak Kumar wrote: No official Java support from Microsoft after December 31, 2007. So, at last they are burying their long dead crippled Java-look-alike obscenity? Fine. We all use SUNs VM for years now. Please do not try to sound like there will be no more Java. Someone might actually believe you. :omg: And those who do not and read the whole story will come to see you as a liar. One does not have to like Java, but at the very least one has to acknoledgr that it inspired MS to bring us .NET :laugh: Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
  • I'm speechless about this piece of code.

    ruby
    34
    0 Votes
    34 Posts
    209 Views
    T
    Michael, I'm far from 100% into C#, like you, I'm a c/c++ guy. (We still have lots of stuff that's says it's c++ but it's mostly old style C). Anyway, this is an issue of getting the types right. And I was just being a smart alec. -- Tony
  • Null != NULL in some cases in asp ;)

    csharp asp-net database sysadmin announcement
    3
    0 Votes
    3 Posts
    19 Views
    M
    At the moment i'm banging my head at the wall. I'm thinking about deleting this piece of source and write it from scratch. But thanks for the link. If i ever get the permission to redesign the complete application, the first thing i will do is switching from ASP to something other. At the moment i prefer C#.
  • Flags constants and new version

    csharp asp-net com question announcement
    2
    0 Votes
    2 Posts
    14 Views
    CPalliniC
    the check: if ((access & ACCESS_ALL) == ACCESS_ALL) will fail on (even ACCESS_ALL) old files. :) If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
  • can somebody explain the logic of this? [modified]

    question
    7
    0 Votes
    7 Posts
    40 Views
    K
    There is missing some logic, as assigning sHafta to a member. I hope so...:confused: Greetings from Germany
  • How to code complicated actuarial formulas in C#?!

    csharp tutorial question
    13
    0 Votes
    13 Posts
    44 Views
    R
    Phil J Pearson wrote: KarstenK wrote: First multiply than divide That happens all too often nowadays. People should work harder at fulfilling their commitment. Or require a licence prior to multiplication