• (unregistered)

    Hi, at least he knew how to ident properly.

  • (unregistered)

    May be a test case to test the no of level for if condition. Is there a limit for nested if in VB?

  • (unregistered) in reply to

    if you scroll the page up and down fast with your scroll mouse, the vb code looks like a sparrow sitting.

  • (unregistered)

    The OK button on the right side, is a MacOSism. (Gnome2-ism too) Well, kind of, it wouldn't say "OK" but a related verb. (generate, save, ..). Not an excuse to do the same on Windows, but it can explain him putting the ok button on the right side.

  • codewulf (cs)

    Wow. I don't even begin to see a reason for this !?!  Wow.

  • (unregistered)

    Is it me, or do 99% of WTF stories start off with "...originally written by a highly paid consultant"?  

  • AerosSaga (cs)

    yes they do, lol

  • (unregistered)

    wow... speachless...

  • (unregistered)

    is see where he went wrong... why whould you check if a boolean = true?

    If optCashReportDay.Value Then 
      DoCashReportDay 
    Else 
      If optCashReportWeek.Value Then 
        DoCashReportWeek 
      Else 
        If optCashReportMonth.Value Then 
          DoCashReportMonth 
        Else...
         [edited for space, not because it's wrong [:P](whatever)]
        End If 
      End If 
    End If 

    laughing all the way to the bank my my 2 cents

  • (unregistered) in reply to

    I'm embarassed that I actually tried the scroll thing.... (BTW, you're right... It does look like a sparrow).

    /BB

  • (unregistered)

    Here's one way to make the code more readable, I am not a VB programmer so the code may not be exactly correct.

    Select Case True

       Case optCashReportDay.Value 
         DoCashReportDay  
       Case optCashReportWeek.Value 
           DoCashReportWeek  
       Case optCashReportMonth.Value
             DoCashReportMonth

    etc.........

    End Select

    Dave


     

  • fcarlier (cs)

    Do you think he did it because the sparrow? ;)

  • (unregistered)

    Um, guys? It's not a sparrow.

    Scroll up and down real fast and you'll see it.

    It's actually quite obscene.

  • (unregistered)

    Oh my...I see it!

    Eww.

  • rlewallen (cs)

    Your case statement is more readable Dave, but isn't the solution for this logic.

    All of this should be replaced with a base class for Report and subclasses for Cash, Bond, Stock, Option, Asset etc each overriding Report() of the base class with a parameter that dictates the timespan for the report.

  • Jacob K (cs)

    [+o(] That just hurts. I wonder if you could get your hands on a screenshot of this UI?


    Truly... W... T... F...

  • Blue (cs) in reply to rlewallen

    Dave's code wouldn't work, if this was VB.NET and VB.NET is anything like C#.  The value following the CASE keyword must be constant, among other issues.


  • rpresser (cs) in reply to Blue
    Blue:
    Dave's code wouldn't work, if this was VB.NET and VB.NET is anything like C#.  The value following the CASE keyword must be constant, among other issues.
    Nope. All forms of VB that I know of (VBScript, VBA, VB6 and VB.NET) allow any expression after the CASE keyword.   Doesn't even check for type at compile time. Dave's code would work, if it can be called working.
     
  • (unregistered)

    all I can say about this is..   WTF!!!   

  • (unregistered)

    The users would be truly wtf'ed after carefully selecting 10 options, getting back from a cup of coffee and noticing only 1 option got executed.

  • (unregistered) in reply to

    <FONT size=2>When I wrote my initial reply I envisioned the UI as having radio buttons for the various reports so only one would be selectable at a time. If the UI has checkboxes, list boxes or any other way of selecting multiple reports at a time then with some prudent control naming(control arrays) a FOR EACH loop would solve the problem. </FONT>

    <FONT style="BACKGROUND-COLOR: #efefef" size=2>Dave</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef" size=2></FONT> 

  • icelava (cs) in reply to
    :
    Um, guys? It's not a sparrow.

    Scroll up and down real fast and you'll see it.

    It's actually quite obscene.

    I think that is exactly what he was doing - ASCII scroll animation in his code.

    Either that, or I would love to see his algorithm for a chess game.

  • (unregistered)

    Did he at least set it up as a radio button?

    Or can you check multiple reports and only get the first one?

  • Blue (cs) in reply to rpresser

    rpresser,

    I didn't know that about VB.  I suppose they don't have to break out of a case to prevent fall-through, and they don't have to worry about only one case block executing either...

    I never cease to be amazed that such a WTF-based language can continue to exist. 



  • Blue (cs) in reply to Blue

    For the rest - that wasn't intended as an anti-VB troll, and I know that atrocities exist in ALL languages, but one has to admit that VB is rather chock-full of them.

  • (unregistered) in reply to Blue

    Blue:
    For the rest - that wasn't intended as an anti-VB troll, and I know that atrocities exist in ALL languages, but one has to admit that VB is rather chock-full of them.

    Blue - appreciate your clarification, but this site would be better if folks would withhold comments generated purely from their disdain of VB as a language. 

    How about just criticizing the misuse of the language (the ostensible topic of the WTF), given that no matter how you might dislike VB's design there are right and wrong ways to do something in it?  Seems to me that'd be more constructive.

    ~Bob (a reluctant VB user)

  • Blue (cs) in reply to

    ~bob - Point taken.  Again, for the record, it is quite possible to create world-class code in VB or nearly any other language.


  • Jeff S (cs)

    Never mind the nested IF.  The biggest problem is that the following functions (or perhaps subroutines) exist:

     DoBondReportDay 
    DoBondReportWeek
    DoBondReportMonth
    DoBondReportAnnual
    ...

    Maybe a single function or two that you pass a date range parameter would be a little more organized and easier?  How much redundant code do you think there is in each of these functions?

  • (unregistered) in reply to rlewallen

    rlewallen:
    Your case statement is more readable Dave, but isn't the solution for this logic.

    All of this should be replaced with a base class for Report and subclasses for Cash, Bond, Stock, Option, Asset etc each overriding Report() of the base class with a parameter that dictates the timespan for the report.

     

    Agreed, if there is time to do this. We all know that there is not always time to refactor a horrible part of code (even when we were the ones who introduced it). I will not comment on how it should have been done this way from the get go because I do not know the vintage of the original code - yes I still have some VB 3 stuff floating around that has not needed to be changed or the time is not there to refactor it.

    This screams of a non VBer working in the language, and somewhat inexperienced because of the different routines to run the same report over different time frames. Smells of newbie fresh out of college.

    At the bare minimum I would break out the nested ifs into separate groups of nested ifs based upon each report type. Given we are running reports the extra time to run the ifs is minor (my opinion) and the readability would go way up. Changing them to elseifs would spike that further. Refactoring to at least minimize the number of routines called, contral arrays (or the .net equivilent) for each report, or as recommended into a base class/subclass set would be my next steps.

    Completely revamping the UI would probably be best (along with the base class route), but users tend to get attached to such things. As such this would actually be the biggest time hit because you would need to do some work with users to determine what would be the best way to handle this screen. As horrible as the screen sounds, this maybe EXACTLY what the users wants & needs.

  • (unregistered)
    <font color="#000000">Wouldn't it look and work more efficient this way (if not used 'case')?
    Problem of for loop would be deciding which procedure to call,
    or you could make a function based on index, but its a matter of taste.</font>

    If
    optCashReportDay.Value = True Then DoCashReportDay
    ElseIf optCashReportWeek.Value = True Then DoCashReportWeek
    ElseIf optCashReportMonth.Value = True Then DoCashReportMonth
    ElseIf optCashReportAnnual.Value = True Then DoCashReportAnnual
    ...
    End If
  • rpresser (cs) in reply to Blue
    <FONT size=2>I didn't know that about VB.  I suppose they don't have to break out of a case to prevent fall-through, and they don't have to worry about only one case block executing either...
    Nope, we don't. The language provides that only the first matching case will execute; the next "Case" clause acts as a break.  It's much more closely related to if/elseif than it is to C's switch/case.
    I never cease to be amazed that such a WTF-based language can continue to exist. 
    </FONT>
    <FONT size=2>And I never cease to be amazed at the insularity and fanaticism of certain programmers who are extremely devoted to their favorite languages. [:D] Granted that the differences can certainly trip up someone who is switching, but once you're used to them, why complain?</FONT>
  • rpresser (cs) in reply to rpresser

    Gaarrr.  I didn't realize there was a second page of comments until I'd posted my reply above. The continuing discussion on the second page clearly makes the last paragraph of my post both unnecessary and unwarranted.  I apologize...

  • Blue (cs) in reply to rpresser
    rpresser:
    Gaarrr.  I didn't realize there was a second page of comments until I'd posted my reply above. The continuing discussion on the second page clearly makes the last paragraph of my post both unnecessary and unwarranted.  I apologize...


    No worries.  The first part of your message is interesting though... If only the first matching case executes (which is what I thought at first, and was asking about), then using a case statement to solve this is NOT in fact doable - if I chose 5 reports, only 1 would print!


  • Jon Limjap (cs)

    I'll try to look for a longer nested-if in our bank software.

    Apparently it's the tyranny of VB 5 not having Select Case... End Select

  • marvin_rabbit (cs)

    Last Post!  Woot!!

  • olddog (cs) in reply to marvin_rabbit

    with enough forward speed ( to the right )  this code could lift-off.

  • Ville (unregistered)

    I mean, with ElseIf it actually would look a bit more reasonable:

    If optCashReportDay.Value = True Then
        DoCashReportDay()
    ElseIf optCashReportWeek.Value = True Then
        DoCashReportWeek()
    ElseIf optCashReportMonth.Value = True Then
        DoCashReportMonth()
    ElseIf optCashReportAnnual.Value = True Then
        DoCashReportAnnual()
    ElseIf optBondReportDay.Value = True Then
        DoBondReportDay()
    ElseIf optBondReportWeek.Value = True Then
        DoBondReportWeek()
    ElseIf optBondReportMonth.Value = True Then
        DoBondReportMonth()
    ElseIf optBondReportAnnual.Value = True Then
        DoBondReportAnnual()
    ElseIf optStockReportDay.Value = True Then
        DoStockReportDay()
    ElseIf optStockReportWeek.Value = True Then
        DoStockReportWeek()
    ElseIf optStockReportMonth.Value = True Then
        DoStockReportMonth()
    ElseIf optStockReportAnnual.Value = True Then
        DoStockReportAnnual()
    ElseIf optOptionReportDay.Value = True Then
        DoOptionReportDay()
    ElseIf optOptionReportWeek.Value = True Then
        DoOptionReportWeek()
    ElseIf optOptionReportMonth.Value = True Then
        DoOptionReportMonth()
    ElseIf optOptionReportAnnual.Value = True Then
        DoOptionReportAnnual()
    ElseIf optAssetReportDay.Value = True Then
        DoAssetReportDay()
    ElseIf optAssetReportWeek.Value = True Then
        DoAssetReportWeek()
    ElseIf optAssetReportMonth.Value = True Then
        DoAssetReportMonth()
    ElseIf optAssetReportAnnual.Value = True Then
        DoAssetReportAnnual()
    Else
        'And so on .... seriously
    End If
    
  • Sindel (unregistered)

    Clever, clever, but it's "if"s all the way down.

Leave a comment on “Innovations from the Inventor of the &quot;ElseIf&quot;”

Log In or post as a guest

Replying to comment #:

« Return to Article