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
  • Reflection Optimization

    ruby algorithms performance question
    16
    0 Votes
    16 Posts
    0 Views
    L
    Thanks. Who knows, but probably it was just an accident. When someone really disagrees it would be more interesting to read his reply. At least artificial intelligence already is superior to natural stupidity
  • Statics

    11
    0 Votes
    11 Posts
    0 Views
    B
    Shocking! public class SysAdmin : Employee { public override void DoWork(IWorkItem workItem) { if (workItem.User.Type == UserType.NoLearn){ throw new NoIWillNotFixYourComputerException(new Luser(workItem.User)); }else{ base.DoWork(workItem); } } }
  • return value optimization

    javascript algorithms performance question
    16
    0 Votes
    16 Posts
    0 Views
    J
    BobJanova wrote: Can't you just cast to boolean instead of using !!? Yes, you could. Casting could be done using return Boolean(flag); Note that return new Boolean(flag); would return a Boolean object whereas without the new keyword, you'd be casting to a Boolean primitive. Greater clarity could be effected by using the triadic operator: return flag ? true : false; or you could use short circuiting, viz return flag && true; but using ! ! flag is more succinct. (I noticed yesterday a piece of jQuery that used !1 for false - I wouldn't go that far in obfuscation).
  • Constant Headache

    database com
    12
    0 Votes
    12 Posts
    0 Views
    A
    Yeah, I can't find a reference to this anywhere aside from online forums. It would be neat if there's a way to disable it (like VB's option strict). Thou mewling ill-breeding pignut!
  • Kinda guy

    question
    7
    0 Votes
    7 Posts
    0 Views
    M
    Agree with you.
  • Problem?

    csharp javascript html asp-net database
    2
    0 Votes
    2 Posts
    0 Views
    B
    Maybe he just wants tables, not the random crap (not working in some browsers) you can get from using an ASP control.
  • Really???

    database help question
    3
    0 Votes
    3 Posts
    0 Views
    B
    Sounds like it was written by someone who doesn't really know SQL. They are only worth keeping around if they can be trained to do it the right way. If they argue that their way is perfectly fine, then chuck them out the door. Just because the code works, it doesn't mean that it is good code.
  • bad SQL case

    database
    6
    0 Votes
    6 Posts
    0 Views
    K
    I just posted "Really???" talking about a 790 line sproc. At least the original author seems to never have heard of CASE before. :laugh: I'm hoping the batches and enums were different each time. :) (doesn't make it any better.) I'm not a fan of CASE, but I've just hit two updates in a row with minor changes that could be handled better with a few well placed CASE statements. Peppered throughout this, it joins a field with 6 function calls to a passed tabular type, then to make extra sure, (s)he put in a matching where clause. I'm thinking that's 1.2 million function calls if there are 10K records in the table and 100 records in the passed table. Nope, it's only 600+K records. The join being mostly false, the WHERE will never be hit. Anyway, I'm a new hire too. Expect some flack as well. If you're curious, see if what I posted beats your's. I think it did.
  • Quick Nap

    17
    0 Votes
    17 Posts
    1 Views
    S
    Every day, I work a micromillenium. Just think of it as evolution in action.
  • Thats why i hate c++

    c++ help learning
    77
    0 Votes
    77 Posts
    84 Views
    L
    "here is the software" file has a virus
  • Classic literature still relevant

    algorithms oop
    4
    0 Votes
    4 Posts
    0 Views
    S
    Well, that "tripe" was written by Dr. Dijkstra who is considered to be the father of programming languages and much of the framework of what we call computer science today. If you actually read the beginning it was also written in 1968, on a typewriter. You ever seen one, child? There is no spell checker on an IBM Selectric. I also have seen developers today utilize GOTO: in C# which makes me shudder!
  • Microsoft "help"

    algorithms help question
    13
    0 Votes
    13 Posts
    0 Views
    S
    Agreed about the examples though I finally found out how they are created and feel more for the creators and the process than the examples. Anyone that works in Microsoft Consulting is expected to "remain up to date on most current technology". Of course, the only way to demonstrate that is to write samples of the code. So they are required to be the ones to create the examples, usually at night, after 8-10 hours of coding for a client, when they should be spending time with their families.
  • The Code Repeater

    question
    14
    0 Votes
    14 Posts
    1 Views
    S
    However, once promoted to a manager they then make decisions on how all programmers should write their code. And they use their own code as a perfect example. Had one manager who refused to let any developer rewrite the systems that the manager had written!!!
  • the outsourcing curse strikes again!!

    csharp asp-net security business tutorial
    29
    0 Votes
    29 Posts
    3 Views
    S
    We had an Indian company taking our code and converting it. In our initial discussions I stated two architectural requirements and they later stated I never said them!!! Then they said that they wanted more money due to meeting my specs. So when we had our next big meeting I gave them the requirement of 300 txn per second and would not let the Indian move away from the subject until he wrote it down on the board as a requirement. (he tried to pass over it stating that it was "standard" or some kind of bull cookie)
  • SetDate

    help question
    13
    0 Votes
    13 Posts
    1 Views
    R
    Fire him! No Luddites allowed!!! "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
  • Why did I do that?

    csharp help question
    10
    0 Votes
    10 Posts
    1 Views
    L
    On the one hand, it's good to continually look for ways to code elegantly in the place you find yourself. On the other hand, there's no shame in keeping it simple and programming in a way that is mutually recognizable across a number of languages. If the language-neutral version is hard to understand and you learn a better way in the language, just refactor it. Changing to something simpler and smaller is generally safer than the long slow trudge in the other direction that any code base tends to make over the years. :) I never saw much point in someone saying "I'm a C# developer" or "I'm a Java developer" or "I'm a C++ developer", like a single platform was a career or something. A successful career will outlive anything specific we know. The real deal is in a deep understanding of the patterns of design and usage that apply across platforms and being curious enough to learn what you would use to express them on several common ones and at least one emerging one.
  • Doh!

    4
    0 Votes
    4 Posts
    0 Views
    E
    Watch out, in some languages the ^ operator is XOR, instead of exponentiation - you still might not have it right!
  • 0 Votes
    19 Posts
    2 Views
    C
    Robert Rohde wrote: Don't be so fast with such statements. Have you tested your approach? I made a quick test and the params keyword introduces a really big performance penalty (more than factor 5, probably even 10). The reason is probably that for each call an array must be instantiated. LOL ... I hadn't thought about that! Good point. No ... I hadn't gone through a rigorous test of the code performance. If the performance loss in my approach is that bad then, yes, it's better to have the eight entry points. I stand corrected. Too bad, though, that a convenient construct like that isn't optimized for performance because it is an obvious case where you would want to use something like that. I'm sure it could be optimized. Doesn't seem like it would be hard to get it to assemble down to a simple stack pointer movement to make room for the params argument. Whatever ... ;-) -CB :-)
  • Format Date

    ruby
    6
    0 Votes
    6 Posts
    0 Views
    S
    Is this written in C#? :confused: I guess the more simpler way would be. date.ToString("yyyy-MM-dd") out puts the date as 2012-04-18 or date.ToString("yyyy-M-dd") out puts the date as 2012-4-18 If not C# Kudos to you ;) Sastry
  • 0 Votes
    6 Posts
    0 Views
    B
    :laugh: :laugh: :laugh: :laugh: :laugh: Posted from my iPad! Attempting to load signature... A NullSignatureException was unhandled. Message: "No signature exists" All of the books in the world contain no more information than is broadcast as video in a single large American city in a single year. Not all bits have equal value. Carl Sagan