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
  • Egregious Use of Flash

    csharp adobe question
    12
    0 Votes
    12 Posts
    0 Views
    pkfoxP
    Still down for me , get a 404 error - weird !!
  • What do u do if today is a chirstmas day?

    question
    3
    0 Votes
    3 Posts
    0 Views
    N
    I drink rather then your preferred recreation of smoking copious quantities of crack. Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
  • Cut out for Greenpeace...

    learning collaboration help
    8
    0 Votes
    8 Posts
    0 Views
    B
    Yeah, that does sound pretty scary. It is expecially bad that he is a technical director. :sigh: Just because the code works, it doesn't mean that it is good code.
  • Bad Websites

    html com sysadmin question
    4
    0 Votes
    4 Posts
    1 Views
    M
    They bring up the most earth-shaking new, I suppose :^)
  • String.Format - I'm sure there must be a worse way to do this.

    hardware
    18
    0 Votes
    18 Posts
    1 Views
    L
    I would think this is how it's supposed to be done. string Daternator() { DateTime dt = DateTime.Now; string result = ""; // Failure to use String.Empty - Check // Homemade string concat - Check for (int i = 0; i < 3; i++) { if (i == 0) result += dt.Year.ToString() + ", "; else if (i == 1) result += dt.Month.ToString() + ", "; else if (i == 2) result += dt.Day.ToString() + ", "; // Unnecessary code - Check } // More unnecessary code to fix previous unnecessary code - Check result = result.Remove(result.LastIndexOf(" "), 1); result = result.Remove(result.LastIndexOf(","), 1); // My lord, he wouldn't... Start: // And what's this? Regex? Fancy! MatchCollection mc = Regex.Matches(result, @"\\b(\\d)\\b"); // I like where this is headed... foreach (Match m in mc) { if (m.Success) { result = result.Insert(m.Index, "0"); goto Start; // Oh lord, he did, a goto loop - Check } } // Sweet sciency magic we have a result!! return string.Format("Application - \[{0}\] - " + result, this.Person.RegistrationNo.ToString()); }
  • Hey kids, what day is it?

    question
    13
    0 Votes
    13 Posts
    1 Views
    L
    Definitely WTF worthy. :) You have my sympathies.
  • Familiarity : Trimming leading and trailing spaces from a string...

    12
    0 Votes
    12 Posts
    16 Views
    L
    I feel your pain - points to your signature.
  • New Exception Type.

    help question
    7
    0 Votes
    7 Posts
    1 Views
    F
    Microsot? Is that a tiny barfly? Fletcher Glenn
  • "Ximba!"

    6
    0 Votes
    6 Posts
    0 Views
    Z
    hmm...probably the original dev loved this place or he was hinting something about it this way :confused: My cUr10U5 w0rlD
  • 0 Votes
    19 Posts
    0 Views
    T
    Tried many times - with OS/2, Linux, FreeBSD, QNX... hell knows how I hate ugly Windows but still have to use it. Now I'm developer, hooked on .NET;
  • another extension

    ruby com help
    4
    0 Votes
    4 Posts
    0 Views
    V
    You are right! Shame on me... ;P :laugh: Regards Vallarasu S | BreakingDotNet.blogspot.com
  • Profanity in code

    csharp
    36
    0 Votes
    36 Posts
    2 Views
    I
    As recently as yesterday, a colleague sent me an email that was supposed to include the word "assign". However, she transposed the last two letters :)
  • CSS selector of the day

    c++ css architecture
    13
    0 Votes
    13 Posts
    0 Views
    C
    Empty anchors don't always work. They should. They don't. cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
  • They grow up so fast..

    collaboration career
    8
    0 Votes
    8 Posts
    0 Views
    J
    We've got them too. I have to rely on an in house component that dynamically changes the datasource in a particular GIS file type. You have to give it the path to the file you want to change and a new filename for the changed version. If you pass it two nulls or two empty strings or two strings that have never been anywhere near a valid path or filename, it runs through without a peep. If you pass it a null or empty path and a valid new file name it creates an empty file with the name you gave it. If you feed it with correct parameters it also runs through without making any noise, so every single piece of software that uses this component has to check the paths are valid and that the created file at least isn't empty. I guess it's taking the single responsibility principle a little too far :)
  • Parsing string to Integer with try and catch???

    xml json question
    18
    0 Votes
    18 Posts
    2 Views
    Z
    Hmm.. i see such silly mistakes being done all the time by fellow colleagues. This is due to the fact that, folks think they are good at their code and langauge grip. Inact, they should know that the art of programming has to be tinkered every day, then only such mistakes can be avoided. But hey, its the big EGO :x My cUr10U5 w0rlD
  • Can you call a method on an object that is null?

    csharp question
    11
    0 Votes
    11 Posts
    1 Views
    H
    I am not a C# person, but in C++, you can call a static method through a pointer that is NULL: { CBlah* pBlah = NULL; pBlah->SomeStaticMethod(); // legal if SomeStaticMethod() is static CBlah::SomeStaticMethod(); // [same thing] } Calling the method requires the right access level (ie. private/protected/public) and a value may or may not be returned by the API (ie. 'void', 'int' etc.). This is not valid in java, and I don't know if it is valid in C#. -- Harvey
  • Infinate levels of hierarchal data

    database
    12
    0 Votes
    12 Posts
    0 Views
    A
    Nice alternative, but not sure how easilly it could be used to power a menu control. With regards to reducing SQL work I can see that it would have benifits.
  • C# Exception handling 101

    csharp python regex question
    8
    0 Votes
    8 Posts
    0 Views
    J
    Nope. I'm mostly working in Silverlight, but this is backend code for a webservice, so ASP.NET. I don't see any reason to 'force' you to write bad exception handling code, ie catching Exception, then testing type. 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
  • C# properties and type safety

    csharp python question
    9
    0 Votes
    9 Posts
    1 Views
    S
    I've seen stranger DateTime usage in the Web Service I'm working on. We use a nullable type too, but in this case it was a WTF because Microsoft handed us a WTF with WCF. Stranger is our code that handles a DataSet which has a DateTime column as part of an incoming web request. Whenever we get new developers on board, we watch them when they come across this piece of code. Some of them slump down in their desks and go into a trance, while some quickly walk away and wash their hands with plenty of SOAP. :) SG Aham Brahmasmi!
  • Thank god the else part is not the same!

    json com
    5
    0 Votes
    5 Posts
    2 Views
    P
    Because sometimes it's not enough to evaluate it once. I suppose, for good measure, he could have put an Enum val = (Enum)Enum.Parse(enumType, name); immediately after the for. *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington "Mind bleach! Send me mind bleach!" - Nagy Vilmos CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier