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
  • Efficiency redux

    ruby
    21
    0 Votes
    21 Posts
    3 Views
    L
    My choice: payment per hour + a realistic manhour estimation + a boss who plays fair and understands that things change + trusted, honest employees + a pizza-day at least once a week. Greetings - Jacek
  • You know it's time to go home...

    6
    0 Votes
    6 Posts
    0 Views
    H
    This is SO much going into my code, one way or another... Epic win!
  • 1,2,3,4...lots of...what exactly?

    csharp java php question
    5
    0 Votes
    5 Posts
    0 Views
    L
    CIDev wrote: defensive offensive coding FTFY :-)
  • 0 Votes
    3 Posts
    0 Views
    B
    That's called obfuscation. Theoretically, it could be intended (protection against reverse engineering, or just abuse of the colleagues who have to maintain that code). But more often, it happens due to other factors. E.g. the law of thermodynamics: things get worse under pressure. Or medical conditions like hypocaffeinemia.
  • Aaaarg....use the namespace

    csharp c++ java php
    31
    0 Votes
    31 Posts
    1 Views
    Sander RosselS
    Really? I was never able to find it. Just right click and...? It's an OO world. public class Naerling : Lazy<Person>{ public void DoWork(){ throw new NotImplementedException(); } }
  • It's duplicated, too lazy to fix.

    data-structures help
    7
    0 Votes
    7 Posts
    0 Views
    L
    Hopeless. Those who go for 'easy' usually don't see the need for any pesky constraints and want to keep on going without them. At least artificial intelligence already is superior to natural stupidity
  • Make sure this value is returned...

    linux
    9
    0 Votes
    9 Posts
    0 Views
    R
    My guess is that this was "skeleton" code that the coder copy pasted but forgot to fill.
  • A new definition of efficiency

    question learning
    11
    0 Votes
    11 Posts
    0 Views
    E
    I think you meant: string _chars = "0123456789abcdefghijklmnopqrstuvwxyz"; (lowercase) :) 65 = A, 97 = a Your version is definitely more readable (and efficient). Based on the default List length, it might reallocate (and copy) the memory backing the list a few times.
  • What about this gem?

    csharp ruby data-structures question
    6
    0 Votes
    6 Posts
    0 Views
    J
    Actually, that would be a very logical thing to do if the size of the array could change and the requirement was that the last element of the array be set to that particular value. If that's the case, I'd prefer the "1" to be a const int rather than hardcoded. And some comments would also be nice.
  • This guy don't know what margin property in CSS is.

    css sysadmin
    5
    0 Votes
    5 Posts
    0 Views
    _
    ..Wow.!!! New margin style.. :laugh: I'll try it in .Net Framework-10.0 . :laugh: :laugh: Read the article "Table Valued Parameters". --Amit
  • Evolution of a stored proc

    debugging
    12
    0 Votes
    12 Posts
    0 Views
    K
    The size of the proc is scary enough, but here's the scariest thing in my opinion. Added IF condition on 4/Nov/2009 as suggested by Manager. Changed the Where Clause on 18/November/2009 as asked by Manager Really? What do system analysts do in this company? :doh:
  • Dating

    help question java
    10
    0 Votes
    10 Posts
    0 Views
    U
    I can't believe it took 4 posts before someone said something. :cool: Membrane.Inside("Insane");
  • When to check for null ?

    csharp linq asp-net database architecture
    32
    0 Votes
    32 Posts
    1 Views
    L
    Or you come here[^]. We have the right kind of glas for that :) At least artificial intelligence already is superior to natural stupidity
  • Dictionary Misuse

    ruby
    10
    0 Votes
    10 Posts
    2 Views
    F
    And the reliance on tools bites you as you comment on it ...
  • RateOfInterest...

    csharp asp-net com sysadmin json
    14
    0 Votes
    14 Posts
    0 Views
    P
    BobJanova wrote: 30 lines where 5 would do is a problem Well I wouldn't write it that way, but I don't consider it a problem (certainly a smell though) and wouldn't necessarily change it if it works properly -- it ain't broke, there's probably more important things to do than to clean this up. However, the OP says that this is just one small example, so perhaps revisiting all of it is worthwhile in this case.
  • Just a C++ tutorial

    c++ com tutorial
    14
    0 Votes
    14 Posts
    2 Views
    V
    This tutorial should be called: "How to get your first access violation runtime error in C++".
  • ToString() and ToUpper() are like, so cool!

    question
    11
    0 Votes
    11 Posts
    1 Views
    T
    Rated 5 for your use of that humorous and archaic phrase. :) If you think 'goto' is evil, try writing an Assembly program without JMP.
  • Multithreading done "right"

    performance question
    24
    0 Votes
    24 Posts
    0 Views
    F
    If there's version control in place, have a look - it might be that previous versions had some code between .Start() and .Join().
  • Great implementation

    6
    0 Votes
    6 Posts
    1 Views
    H
    Tell the compiler/computer to execute each new "IsChecked" invocation as double as fast as the current "IsChecked" invocation. Since 1 (the time of the first IsChecked) + 1/2 (the time of the second IsChecked) + 1/4 + ... + 1/2^n converges to 2 for n -> Inf, you have the result of "IsChecked" in 2 time units ;) But Achilles wishes from Zeus, who executes every wish, that his wish mustn't come true and the world crashes... (that was an insider from the same book) If you find spelling- or grammer-mistakes, please let me know, so that I can correct them (at least for me) - english is not my first language...
  • Is it? Has it changed? What about now?

    security question
    18
    0 Votes
    18 Posts
    0 Views
    A
    Some additional ones: Three is a magic number. (Schoolhouse Rock) What I tell you three times is true. (The Hunting of the Snark; Lewis Carroll)