Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

David St Hilaire

@David St Hilaire
About
Posts
6
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • VB Select Case statement incarnation of C# if (true = [condition])
    D David St Hilaire

    Why? Normally the test expression is evaluated at runtime, and the result is compared to each case until a match is found. In my experience, the case expressions are usually constant, and they are usually unique values (in C# & C++ these behaviors are enforced). Here, the test expression is the constant, and the case expressions are calculated at runtime. And, since in the actual example there were several expressions that were returning boolean results, there were several cases that would have the same values. That is what I mean by backward. It certainly works, and maybe it just struck me as odd because my background is predominantly C++ & C#. But, the company I'm at has a large body of VB.NET code and this is the only instance I've seen of a case statement done this way. And, it is backward compared to the example in MSDN as well. It seems like if you want to evaluate a series of expressions until you find one that is true, using an if-then-elseif would be more appropriate. Just my opinion.

    The Weird and The Wonderful csharp help

  • VB Select Case statement incarnation of C# if (true = [condition])
    D David St Hilaire

    I saw this at work. I guess the coder wanted to do a series of validations and return an error when the first failure condition was found. I don't know if you'll consider this a horror or not, but it is definitely a backwards way of doing this.

    Select Case (true)
    Case [failure condition 1]
    Throw New Exception("Condition 1 failed.")
    Case [failure condition 2]
    Throw New Exception("Condition 2 failed.")
    'etc...
    Else
    'Success!
    End Select

    The Weird and The Wonderful csharp help

  • To me this is a coding horror, and to you? [modified]
    D David St Hilaire

    I see a lot of:

    if (b1)
    b2 = true;
    else
    b2 = false;

    and even some:

    switch (b1)
    {
    case true:
    b2 = true;
    break;
    case false:
    b2 = false;
    break;
    }

    The Weird and The Wonderful question

  • Oh man...
    D David St Hilaire

    Can you explain the horror? At first I thought you were getting a value from a text box and putting it right back into the text box, but after closer inspection I see that isn't the case (assuming the language is case-sensitive).

    The Weird and The Wonderful com

  • goto statement [moved]
    D David St Hilaire

    How about if I try to help him out with this code sample I came across from someone who was apparently trying to avoid using a goto? I don't have access to the actual function anymore, but the basic idea went: do { //some code here if ([condition]) break; //some more code here if ([condition]) break; //this goes on for awhile.... if ([condition]) break; // ... } while (false); // clean up code

    The Lounge question discussion

  • SetFocus.com
    D David St Hilaire

    Does anyone know anything about the SetFocus training organization (setfocus.com)? Is it for real, and is it worth it?

    The Lounge com question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups