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
  • Quotes of the day:

    database tools announcement
    6
    0 Votes
    6 Posts
    3 Views
    M
    You have my utmost condolences... X|
  • Making shortcuts even shorter

    javascript announcement
    10
    0 Votes
    10 Posts
    3 Views
    L
    appreciate ur guts to write these lines of code Ravie Busie Coding is my birth-right and bugs are part of feature my code has!
  • Not really a horror, but useless all the same

    com game-dev question
    8
    0 Votes
    8 Posts
    2 Views
    M
    I don't see the horror...
  • To me this is a coding horror, and to you? [modified]

    question
    84
    0 Votes
    84 Posts
    12 Views
    M
    heh Actually, I blame people like for cryptic names of C++ functions... I know a few decades ago consiness was important, but I don't like that in C++ programmers still do this, even though you can easily use self explaining names these days and aren't limited by memory size.
  • Need to vent...

    sales tools help announcement
    13
    0 Votes
    13 Posts
    2 Views
    T
    Megidolaon wrote: What is the point of if (node.Attributes\["Publish"\].InnerText.Trim().Contains(s)) { return; } A check for containting a single letter and then doing nothing? No, that loop checks if the node text contains one of the non-translatable strings and if so, bails. Megidolaon wrote: Maybe the XML contains trailing spaces? Unless you trim them, the XML Nodes' InnerText wouldn't equal the DictionaryEntries with same You are correct, however within a given call to TranslateNode(), the xml node stays the same. Until it gets translated from the dictionary. Oh crap, there's yet another bug in there that I hadn't noticed - it can double translate. Anyway, the phrase node.Attributes["Publish"].InnerText.Trim() should be invariant, and I assume it takes some processing. So a line like: string xmlText = node.Attributes\["Publish"\].InnerText.Trim(); and then refering to that string wold have been more efficient,and easier for me to read, I think. -- T
  • 16 layers of ifs, Who dare challenge this?

    question
    29
    0 Votes
    29 Posts
    5 Views
    M
    16 layers...that guy must be insane :~ modified on Friday, February 27, 2009 6:54 AM
  • Magic C++ Program

    c++
    14
    0 Votes
    14 Posts
    6 Views
    M
    wow, You ca really **** up your code with C++... :laugh:
  • C# - Arrays vs Arraylist

    csharp ruby visual-studio data-structures performance
    13
    0 Votes
    13 Posts
    5 Views
    M
    I don't get why people cling to arrays in C#, they are less easy to use than egneric Lists and hvae a similary large overhead (the amount of methods available for an array is pretty much the same as for a List). From what heard there is also no speed improvement. And Arraylist should be used as rarely as possible, if all elements have the same type, it's easier to work ith them instead of first having to cast each object. Besides worker threads, that only have 1 object as possible parameter, I can't think of the nedd to hae differnt bkect types in the same collection. modified on Tuesday, February 24, 2009 9:16 AM
  • Words cannot describe my pain

    php visual-studio linq com beta-testing
    13
    0 Votes
    13 Posts
    5 Views
    CPalliniC
    Are you his boss? :rolleyes: 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. This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke [My articles]
  • I wonder!!!!

    question csharp dotnet
    20
    0 Votes
    20 Posts
    2 Views
    M
    Actually this doesn't force the developer to do anythin, on the contrary. It allows to use simple class names instead of full class names. If you hvae a name that can refer to more thsn 1 class, you get a compiler error and forced to use the full name, regardless of usings. But usings that are not use at the beginning of the file but at the beginning of a namespace sounds like more like an accident than anythign else.
  • What will you call this???

    question workspace
    23
    0 Votes
    23 Posts
    1 Views
    M
    *points and laughs* Pointless. Really. The DateTime class can can convert a string to date. Separating the both dates must be done manually, but the conversion can be done by the DateTime class.
  • Avoid return statement in the middle - horror or not?

    question
    59
    0 Votes
    59 Posts
    67 Views
    M
    Ever thought about using &&?
  • Somewhat of a jem...

    7
    0 Votes
    7 Posts
    2 Views
    L
    Perfect for a Scheme macro, oh wait! You are not using Scheme! ;P xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
  • True/False Dichotomy

    6
    0 Votes
    6 Posts
    0 Views
    L
    I would love to have macro-definitions in C# or Java just to break all these silly stereotypes. #define max(a,b) (a>b ? b : a) #define min(a,b) (a>b ? a : b) or #define cerr (cin) #define cout (cerr) #define cin (cout) Aaah so confusing so sweet ... ;P Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
  • Magic of if...else...programming

    43
    0 Votes
    43 Posts
    8 Views
    A
    would the same work for a switch statement? switch (null) { case dt: {} break; case dt.rows: {} break; default: {/*actual exec., we have asserted everything's cool*/} } or how about this? switch (true) { case (dt == null): {/*handle the case that dt is null, i.e. assign it something*/} break; case (dt.rows == null): {/*handle the case that dt.rows is null*/} break; case (dt.rows[0]["number"] == 0): {/*this element equals 0, it now needs to be assigned*/} break; default: {/*computer finally does something right*/} break; } maybe nest either one in a do loop till the computer gets its sh*t straight. please tell me why this is wrong, as i am just learning.
  • How to be popular among your colleagues

    csharp help tutorial
    6
    0 Votes
    6 Posts
    1 Views
    N
    Enum NumberSize EightBits = 8 SixteenBits = 16 ThirtyTwoBits = 32 SixtyFourBits = 64 HundredTwentyEightBits = 128 End Enum :) IMHO in this particular case, there is no effective use of the enumeration (see #4). There is no checks on invalid enumeration values either; most common call of the CBin_Number function was performed with argument CType(size, NumberSize) where size is an integer. It is hard to find best practices for enumerations since it just grouped constants. Usually all enumeration replaced by the Strategy Pattern during refactoring (see http://sourcemaking.com/refactoring/replace-type-code-with-state-strategy[^] or http://www.jeremyjarrell.com/archive/2007/10/28/64.aspx[^]). Type casting to enumeration datatype does not do validation, so a callie have to validate enumaration value by itself. However, by decalaring enumeration as Enum NumberSize Bit_8 Bit_16 Bit_32 Bit_64 Bit_128 End Enum you may perform range (in)validation InputNumberSize < NumberSize.Bit_8 OrElse InputNumberSize > NumberSize.Bit_16, it also allows compliler to optimize Select statement code execution. Do you think change NumberSize to an integer type would introduce more problems?
  • I see dumb people

    business csharp database help
    11
    0 Votes
    11 Posts
    2 Views
    N
    I've fell into the same trap; but the original web application was built in ASP and I had to convert it to ASP .NET web app. plus on top of that the share holder is a jerk. Dig deep and stick through it, it'll only make you a better developer. I'm at the end of this conversion and I have learned a lot. Hang in there! -Noir
  • NULL Checking and Defensive Programming

    data-structures performance question
    37
    0 Votes
    37 Posts
    4 Views
    W
    WTF!!!???? :omg: I think I might be close to speechless. Has the man never had a blue screen of death and gotten annoyed? Never thought I'd hear of some genius campaigning for application failure...
  • Percent-decoding a URL

    question
    13
    0 Votes
    13 Posts
    2 Views
    S
    not if its a StringBuilder Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. -Fred Brooks
  • great way to clear asp.net form fields

    csharp asp-net
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied