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
  • Exstream Younit Testing

    php visual-studio com testing beta-testing
    4
    0 Votes
    4 Posts
    0 Views
    W
    lol! that's ridiculous!
  • Bad join [modified]

    help
    7
    0 Votes
    7 Posts
    0 Views
    V
    Jeremy Hutchinson wrote: to handle that monster Is the monster a manager now? :laugh: Vasudevan Deepak Kumar Personal Homepage Tech Gossips The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!
  • Good thing that array's big enough

    data-structures
    3
    0 Votes
    3 Posts
    0 Views
    N
    That is truely awful. Much better would be: mlNumOfSomething = SomeClass.GetSomething(anIDArray()) lItemToAdd = 0 For lli = 1 To mlNumOfSomething SomeClass.GetSomeInfo anIDArray(lli), Description:=aDescription lItemToAdd = lItemToAdd + 1 ReDim Preserve msAllAgencies(1 To lItemToAdd) msSomeArray(lItemToAdd) = aDescription Next lli That way you can add in logic to exclude items. Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H
  • Another fine gem mined from the codebase

    ruby database help career
    5
    0 Votes
    5 Posts
    0 Views
    L
    Wes Jones wrote: the return value is never set 'cause the author was retarded ... Greetings - Jacek
  • Nullabilityatastic

    question learning
    8
    0 Votes
    8 Posts
    0 Views
    C
    you're missing the point, the post is not about Nullable types but Nullable people
  • CBool(IIf(BooleanFunction(), True, False))

    2
    0 Votes
    2 Posts
    1 Views
    W
    That's a mighty nice turd you found there
  • GoSub Return's

    csharp
    6
    0 Votes
    6 Posts
    0 Views
    D
    If you type Wend in Visual Studio in VB code it automatically replaces it with End While. I can't decide whether that's intended to be helpful (we'll fix that for you, sir) or whether it's a subtle nudge (learn the new syntax, dummy!). I must admit, I always rather liked the Let keyword. It seemed like such a polite way to code. I say, old chap, would you mind terribly letting a = b. Thanks awfully.
  • WTF Was This Guy Thinking!!! [modified]

    database csharp sql-server sysadmin help
    16
    0 Votes
    16 Posts
    1 Views
    W
    I think he meant to make a Ladder; Only that it's lying on the wrong wall :laugh: Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
  • .NET Process does not get along with .NET console

    csharp testing beta-testing
    4
    0 Votes
    4 Posts
    0 Views
    P
    Ahh... and it is by design. A little further reading indicates that when redirecting io the underlying io and error streams Console object has NOTHING to do with the console screen that might be displayed albeit blank. This was lost on me initially. Console class members that work normally when the underlying stream is directed to a console might throw an exception if the stream is redirected, for example, to a file. Consequently, program your application to catch System.IO..::.IOException if you redirect a standard stream. http://msdn.microsoft.com/en-us/library/system.console.aspx[^]
  • \r\n

    ruby
    30
    0 Votes
    30 Posts
    1 Views
    M
    David Skelly wrote: reverse engineering it could be a breach of the licence terms But not in Australia: http://www.austlii.org/au/legis/cth/consol_act/ca1968133/s47d.html[^] and it refers to "adaptation" which is defined here: http://www.austlii.org/au/legis/cth/consol_act/ca1968133/s10.html#adaptation[^] at (ba), and that is a definition of decompilation, let alone reverse engineering in general. Of course the OP is in Germany, so that is irrelevant :-) Regards, Mark Hurd, B.Sc.(Ma.) (Hons.)
  • String of Horror

    xml
    4
    0 Votes
    4 Posts
    0 Views
    D
    What feedback did you provide the developer...?
  • How to test equality

    help tutorial question
    20
    0 Votes
    20 Posts
    4 Views
    D
    Definitely not! It means not not, does it not?
  • A new way to create a DateTime from the year!

    help
    8
    0 Votes
    8 Posts
    0 Views
    D
    Huh? How do you know there is input data involved here or that it's not known to be in a valid state?
  • Let's just make sure?

    question
    13
    0 Votes
    13 Posts
    1 Views
    D
    David Skelly wrote: part of the reason for using enums is to constrain the range of values It is indeed. But I think C# strikes the right balance; another reason for using enums is that it provides a more readable alternative to hard-coded ints and a more efficient alternative to string literals. C# does not allow implicit casts to enum values, precisely because it is unsafe. There is no run-time check when explicitly casting because it would introduce significant overhead. I find it rather too strict if Java as you claim does not allow casting to enum types from integer types. Imagine you have a class with many fields that each have a small predefined set of legal values. We can define enums to represent these sets, use byte as the base value, and store such data in a database using one byte per attribute. Storing the names is extremely inefficient: Each column has to be sized according to the maximum length permitted in the set of values. You'd easily go to 20 characters in many cases, and sometimes more, which depending on encoding will require 20 to 40 bytes of storage space. If you have five such fields, you could end up using 200 bytes instead of 5. And large row size == bad performance. If you can't cast to enum values, you'd have to write switches instead (switch (value) { case 1: return CreditCard.MasterCard; break; ...}) which is pretty boring work!
  • if and if not do it anyway

    10
    0 Votes
    10 Posts
    0 Views
    R
    I tell people and tell people and tell people to use parens and not assume people know operator precedence. People tell me I'm stupid. I choose to believe they mean for saying use parens. Walk through it and change the values in the debugger and make a state table. I also go with the XOR interpretation. Opacity, the new Transparency.
  • Don't they know what an array is?

    css data-structures help question career
    30
    0 Votes
    30 Posts
    3 Views
    T
    I hate to admit it, but I've found code like that here from a previous developer. It's also in C#, but the delimiter is a newline. Maybe you have our old developer? public string FormatBarContent(string foo1, string foo2, string f003, // ... string foo14, ) { StringBuilder sb=new StringBuilder(); sb.Append(foo1); sb.Append("\n"); sb.Append(foo2); sb.Append("\n"); // ... sb.Append(foo14); // sb.Append("\n"); return sb.ToString(); } And some of the foo's have been converted from numbers to strings. The routine that gets this string immediately Split()'s it and parses the numbers back into numbers. None of the data ever needs to leave the current thread. Don't they know what a struct is? -- T
  • Who needs childNodes when you have innerHTML?

    html css algorithms question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Wasted space

    tutorial question
    39
    0 Votes
    39 Posts
    0 Views
    E
    Actually, I've always hated that inline if syntax. In fact, my version of that routine would be even longer: private void appendBooleanField( boolean value, boolean lastField ) { strind field; if ( value ) { field = "y"; } else { field = "n"; } appendField( field, lastField ); }
  • Am I missing Something?

    css question
    16
    0 Votes
    16 Posts
    0 Views
    J
    That's correct, I could not imagine why someone would do it like this.
  • Simple yet entertaining

    7
    0 Votes
    7 Posts
    0 Views
    W
    Aaaah, I thought it was my unfamiliarity with linq, geez! Wout