• m0ffx (unregistered) in reply to Sean D

    The most important is carry_on(). That one actually does something before returning. It adds 60's and 70's British comedy to your code.

  • (cs) in reply to Zab Brannigan
    Zab Brannigan:
    This kind of pisses me off! If I saw this at work I become (more?) physically and verbally abusive. I've seen something similar. We had a consultant that was Unix bigot. He created a Unix shell for DOS on his PC by using .bat files and renaming system commands. Of course, after seeing this, another programmer made a DOS shell for Unix.

    I guess he never heard of cygwin...

    Still, MS behavior irritates me, but it isn't worth that sort of hassle.

  • moowar (unregistered)
        Function in_(ByVal ParamArray v() As Object) As Boolean
            If IsArray(v) And UBound(v) > 1 Then
                Dim i
                For i = 1 To UBound(v)
                    in_ = (v(0) = v(i))
                    If in_ Then Exit For
                Next i
            End If
        End Function
    
  • (cs)

    VB is already an ugly syntax with its insistence of using words as code block delimiters. But it seems like whoever did this code didn't think that was enough, as it seems like begin() works basically as a code delimiter.

    Or maybe, just maybe, begin() is actually the Call of Codethulu

  • (cs) in reply to Franz_Kafka
    Franz_Kafka:
    Zab Brannigan:
    This kind of pisses me off! If I saw this at work I become (more?) physically and verbally abusive. I've seen something similar. We had a consultant that was Unix bigot. He created a Unix shell for DOS on his PC by using .bat files and renaming system commands. Of course, after seeing this, another programmer made a DOS shell for Unix.

    I guess he never heard of cygwin...

    Still, MS behavior irritates me, but it isn't worth that sort of hassle.

    Or SFU. (Services For Unix, that is.) It adds a nice Interix subsystem to Windows and you can Unix your way around Windows, using ksh or csh.

  • (cs) in reply to danixdefcon5
    danixdefcon5:
    Franz_Kafka:
    Zab Brannigan:
    This kind of pisses me off! If I saw this at work I become (more?) physically and verbally abusive. I've seen something similar. We had a consultant that was Unix bigot. He created a Unix shell for DOS on his PC by using .bat files and renaming system commands. Of course, after seeing this, another programmer made a DOS shell for Unix.

    I guess he never heard of cygwin...

    Still, MS behavior irritates me, but it isn't worth that sort of hassle.

    Or SFU. (Services For Unix, that is.) It adds a nice Interix subsystem to Windows and you can Unix your way around Windows, using ksh or csh.
    Yes, SFU was a thing of surpassing loveliness. Of course, it was never open-sourced, because that would make no sense at all, would it? And, of course, it's only available on 32-bit systems, which effectively means that it's discontinued.

    The BallRog giveth and the BallRog taketh away.

    Sometimes I wonder what goes on inside Steve's sweaty little Marketing Guru head.

  • (cs) in reply to bluprintz
    bluprintz:
    Looks like someone is trying to implement Aspect Oriented Programming... for Visual Basic.

    The begin() is obviously addressing some cross-cutting concerns.

    Run! Run away now!

    I believe the term you're looking for is Abject Oriented Programming.

    Oh, wait ... there's no difference, is there?

  • CoyneT (unregistered) in reply to h
    h:
    bbobb:
    I see the WTF in the in_() functions. They really only needed the first one; the rest were redundant and limiting. What if they had 22 items? They could have solved it much more elegantly as:

    result = in_(v,p1) OrElse in_(v,p2) OrElse in_(v,p3) ... OrElse in_(v,p20) OrElse in_(v,p21) OrElse in_(v,p22)

    :-þ

    I don't get why he didn't reuse his code for more elegantly problem solvings...

    Public Function in_(ByVal v As Long, ByVal p1 As Long, ByVal p2 As Long, _
                        ByVal p3 As Long, ByVal p4 As Long, ByVal p5 As Long, _ 
                        ...
                        ByVal p18 As Long, ByVal p19 As Long, ByVal p20 As Long _
                        ) As Boolean
        begin()
        Return in_(v,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) OrElse in_(v,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20)
    End Function 'in_(20)
    

    Makes much more sense to me - best practices at their... best..

    Nah. It needs to be the other way:

    Public Function in_(ByVal v As Long, ByVal p1 As Long, ByVal p2 As Long, _
                        ByVal p3 As Long, ByVal p4 As Long, ByVal p5 As Long, _ 
                        ...
                        ByVal p18 As Long, ByVal p19 As Long, ByVal p20 As Long _
                        ) As Boolean
        begin()
        Return v = p1 OrElse v = p2 OrElse v = p3 ... OrElse v = p20
    End Function 'in_(20)
    
    

    Then 19 can be defined on 20:

    Public Function in_(ByVal v As Long, ByVal p1 As Long, ByVal p2 As Long, _
                        ByVal p3 As Long, ByVal p4 As Long, ByVal p5 As Long, _ 
                        ...
                        ByVal p18 As Long, ByVal p19 As Long
                        ) As Boolean
        begin()
        Return in_(v,p1,p2,p3,...,p18,p19,p19)
    End Function 'in_(19)
    
    

    Then the in_(18) function:

    Public Function in_(ByVal v As Long, ByVal p1 As Long, ByVal p2 As Long, _
                        ByVal p3 As Long, ByVal p4 As Long, ByVal p5 As Long, _ 
                        ...
                        ByVal p18 As Long
                        ) As Boolean
        begin()
        Return in_(v,p1,p2,p3,...,p18,p18)
    End Function 'in_(18)
    
    

    See? That way there's only one actual expression to maintain, in the in_(20) function. Everything else gets defined on the 20 parameter version.

    Greatly reduces the potential for bugs in the system.

  • blunder (unregistered) in reply to Satanicpuppy

    A lot of us work on multiple systems. I work on multiple systems. Windows, Mac, Linux, SCO Unix. I don't alias the commands.

    It sounds harsh but it's always just seemed to me to be a redneck way of doing things. They only help in the most basic situations. Even 'ls' does not behave like dir, and they do not support the same switches. The syntax for creating loops is fairly different. So you'd need a lot of aliases. Why go that far for what amounts to putting matching lipstick on a variety of pigs?

    I really wouldn't call it snobbery. It's not like the practice hurts anyone, but you shouldn't be above getting ribbed for it a little, given its hackish nature.

  • JohnFx (unregistered) in reply to Me
    Me:
    I WANNA KNOW WHAT begin() DOES!!!!!

    If a constructor for a class is good thing, then a constructor for each method must be even better, right? The only downside is that you have to roll it yourself.

    On top of that he is promoting code reuse by having all the method constructors call the same block. He just hasn't written the massive case statement that uses reflection to determine which block called it and execute the appropriate intialization code.

    And you guys were skeptical. Sheesh. This guy is a pioneer!

    </sarcasm>
  • (cs) in reply to CoyneT
    CoyneT:
    See? That way there's only one actual expression to maintain, in the in_(20) function. Everything else gets defined on the 20 parameter version.

    Greatly reduces the potential for bugs in the system.

    Well, we're about fifty-odd posts in, and AFAIK, nobody has yet mentioned the oddity of naming a file (with any extension) "CustomerClass."

    "Class"?

    I first realised that I was sickening for something, possibly a gin and tonic, when it occurred to me that I actually understood the VB.NET. This will never do.

    I then started to think about the naming convention. What is this? Is there a "CustomerObject.vb"? And, if not, what's the purpose of adding "Class" to anything? (Not that there is any.) I mean, it's not as if there's any useful-type Hungarian notation prepended to the file name to let us know whether or not it's NQOT ("Not Quite Our Type").

    Maybe it uses .NET reflection to automagically generate a CustomerObject.mdl file. Yes, that would be it. It's VB.NET masquerading as Smalltalk! First Class!

    However, on reflection, you could have a point here. It's more likely to be VB.NET masquerading as a true functional language that relies entirely on recursion (good luck on avoiding the side-effects of ON ERROR RETURN NEXT, but I assume that's an exercise for the reader.)

    Finally, VB.NET embraces Greenspun's Tenth Law!

    PS. What are the other nine?

  • Butter (unregistered) in reply to rg
    rg:
    I think the guy had good intentions with the begin()... end() stuff. Those would make good debugging and tracing hooks, BUT he could not figure out, because it's impossible, how to put in a single end() call and still do a return someexpression from multiple places..
    return end(ReturnVal) Public Function end(Ret as Any) as Any return Ret End Function

    Doesn't solve the issue of being a massive WTF, but it works.

  • (cs)

    This has actually gone through several revisions of 'optimization'. The begin() method used to contain 'sleep(5)', and has since been optimized 5 times.

  • Scott Nelson (unregistered)

    My guess is that he uses the context menu to right-click on the function and then clicks "Definition", that way if the "Begin()" function is at the "beginning" of the document, the cursor goes up there and he is at the top. So that shows another WTF, he didn't know of the "Ctrl+Home" key combo to do that.

  • (cs) in reply to Aaron
    Aaron:
    Public Sub begin_comment() begin() End End Sub

    This joke is getting more annoying than good ole' fist, because at least the fist people know they're being stupid.

  • Function Array_Length (unregistered)
    Public Function Array_Length(ByVal Length As Integer) As Integer
        begin()
        Return Length - 1
    End Function 'Array_Length
    This one just made my head explode. You'd expect that a function called "Array_Length" would, say, return the length of an array, but no... this one takes an integer as its input, substracts one, and returns it. In other words:

    myArray.Length == Array_Length(myArray.Length) + 1

    Or you could replace "while(i < myArray.Length)" with "while (i <= Array_Length(myArray.Length))". Whee?

  • Adam (unregistered) in reply to TopCod3r
    TopCod3r:
    All methods in VB are virtual, and this WTF leaves out important details in determining if the WTF is in the code or in Hank's grossly inadequate VB knowledge.

    No they aren't, that's what the Overridable keyword is for. Before you jump on others' VB knowledge, you may want to check your own.

  • WilliamV (unregistered) in reply to Sean D

    how about go_to() and come_from() ?

  • (cs) in reply to Adam
    Adam:
    TopCod3r:
    All methods in VB are virtual, and this WTF leaves out important details in determining if the WTF is in the code or in Hank's grossly inadequate VB knowledge.

    No they aren't, that's what the Overridable keyword is for. Before you jump on others' VB knowledge, you may want to check your own.

    Um, the overridable keyword does not make a method virtual or not, it just determines whether it can be overridden.

    Unlike other languages (that are inferior to VB), in VB you do not have to specify virtual in the declaration in order to get the virtual behavior.

    I bet my little finger has forgotten more VB than you will ever know.

    By the way, I have passed THREE BrainBench assessments in VB, and scored over 90% on a MeasureUp assessment. My company will be paying for me to pursue the MCAD next year, so I think that tells you all you need to know about by qualifications.

  • (cs) in reply to TopCod3r
    TopCod3r:
    Adam:
    TopCod3r:
    All methods in VB are virtual, and this WTF leaves out important details in determining if the WTF is in the code or in Hank's grossly inadequate VB knowledge.

    No they aren't, that's what the Overridable keyword is for. Before you jump on others' VB knowledge, you may want to check your own.

    Um, the overridable keyword does not make a method virtual or not, it just determines whether it can be overridden.

    Unlike other languages (that are inferior to VB), in VB you do not have to specify virtual in the declaration in order to get the virtual behavior.

    I bet my little finger has forgotten more VB than you will ever know.

    By the way, I have passed THREE BrainBench assessments in VB, and scored over 90% on a MeasureUp assessment. My company will be paying for me to pursue the MCAD next year, so I think that tells you all you need to know about by qualifications.

    Eek!

    We should all learn a lesson from this. Maybe THREE lessons.

  • Rosco (unregistered)

    or, use the params keyword. I know C# has it, and i'm just assuming vbnet has it too.

    then loop through all of the items ...

  • imalc (unregistered)

    Okay it is clear that the author comes from a Pascal or Delphi background.

    What would be really the icing on the cake would be if they went back to using Delphi and then made that look like VB!

  • Maarten (unregistered)

    CEE probably stands for Customer ENTERPRISE Engagement.

  • (cs) in reply to real_aardvark
    real_aardvark:
    We should all learn a lesson from this. Maybe THREE lessons.
    The only lesson I care to draw is that non-virtual methods are a bad dream perpetrated by C++ during one of many fits of "sacrifice much sanity for a little speed".
  • Wessel (unregistered)
    Function In_(Of T As IComparable)(ByVal ParamArray values() As T) As Boolean
            If values.Length Mod 2 <> 0 Then Throw New ArgumentException()
    
            Dim q = From v In values _
                    Let index As Integer = Array.IndexOf(values, v) _
                    Where v.CompareTo(values(index + 1)) = 0
    
            Return q.Count() = values.Count()
        End Function
    
  • Wessel (unregistered)

    Eek!

    Function In_(Of T As IComparable)(ByVal ParamArray values() As T) As Boolean
            If values.Length Mod 2 <> 0 Then Throw New ArgumentException()
    
            Dim q = From v In values _
                    Let index As Integer = Array.IndexOf(values, v) _
                    Where index = values.Count - 1 OrElse v.CompareTo(values(index + 1)) = 0
    
            Return q.Count() = values.Count()
        End Function
    

    Well it's still damn ugly :D

  • (cs) in reply to dkf
    dkf:
    real_aardvark:
    We should all learn a lesson from this. Maybe THREE lessons.
    The only lesson I care to draw is that non-virtual methods are a bad dream perpetrated by C++ during one of many fits of "sacrifice much sanity for a little speed".
    Eek!
  • VB6Coder (unregistered) in reply to Wessel
    Wessel:
    Eek!
    Function In_(Of T As IComparable)(ByVal ParamArray values() As T) As Boolean
            If values.Length Mod 2 <> 0 Then Throw New ArgumentException()
    
            Dim q = From v In values _
                    Let index As Integer = Array.IndexOf(values, v) _
                    Where index = values.Count - 1 OrElse v.CompareTo(values(index + 1)) = 0
    
            Return q.Count() = values.Count()
        End Function
    

    This must be the most evil code I have ever seen. Why should an odd number of parameters cause an exception?

    In VB6, we don't need all that horrible overloading nonsense, we have variants!

  • (cs)

    Perhaps he needed somewhere to put breakpoints.

  • Dark (unregistered) in reply to VB6Coder
    VB6Coder:
    This must be the most evil code I have ever seen. Why should an odd number of parameters cause an exception?
    For those use-cases you would use In_Odd_(), of course. It's not a good idea to try to make a single function do everything.
  • Olipro (unregistered) in reply to Sean D

    One can only assume that he was paid according to the amount of code he wrote, what other logical conclusion can you draw about a man who creates functions that do nothing, and the proceeds to call them from absolutely everywhere?

    And I can just imagine that once he finished, they had a guy review his code, note the dishonesty and promptly fire him with no payment.

  • (cs) in reply to Me
    Me:
    I WANNA KNOW WHAT begin() DOES!!!!!

    Plz send me teh codez

  • (cs) in reply to real_aardvark
    real_aardvark:
    bluprintz:
    Looks like someone is trying to implement Aspect Oriented Programming... for Visual Basic.

    The begin() is obviously addressing some cross-cutting concerns.

    Run! Run away now!

    I believe the term you're looking for is Abject Oriented Programming.

    Oh, wait ... there's no difference, is there?

    Absynth Oriented Programming.

    FTFY

  • (cs) in reply to fuzzix
    fuzzix:
    More accurately, they were the Long set of _in() methods.
    Aren't they in_() methods?
    Though he suspected that the ECC system was yet another tentacle of the great Codethulhu...
    Isn't it CEE?

    The quality of MFD is seeping into the articles! NOOO!

    You must be new here? Codethulhu predates MFD.

  • (cs) in reply to bg
    bg:
    Me:
    I WANNA KNOW WHAT begin() DOES!!!!!
    I WANT YOU TO SHOW MEEE...

    I wanna feel what begin() does I know you can show me

    Now this vb I must fix Feels like a world upon my shoulders Through the goggles I see these horrors It makes me die inside a little more

    In my code theres been end_block() and none() I dont know if I can face block() again Cant stop now, I've travelled so far To fix this CEE system

    I wanna know what true_() is I want you to show me I wanna feel what true_() is I know you can show me

    etc.

  • Innkeeper (unregistered)

    You are all fools! He was using this project to create artificial intelligence. He needed to teach the code every possibility so the computer will gain awareness.

  • dogz (unregistered) in reply to Function Array_Length
    Function Array_Length:
    Public Function Array_Length(ByVal Length As Integer) As Integer
        begin()
        Return Length - 1
    End Function 'Array_Length
    This one just made my head explode. You'd expect that a function called "Array_Length" would, say, return the length of an array, but no... this one takes an integer as its input, substracts one, and returns it. In other words:

    myArray.Length == Array_Length(myArray.Length) + 1

    Or you could replace "while(i < myArray.Length)" with "while (i <= Array_Length(myArray.Length))". Whee?

    I suspect that the code was written by one of those individuals that cannot get their head around zero-based indexes, i.e. the kind of person that uses "Option Base 1" in VB6.

    They should not be allowed to touch computers.

  • cheeseplease (unregistered) in reply to VB6Coder
    VB6Coder:
    In VB6, we don't need all that horrible overloading nonsense, we have variants!
    Go to your room!
  • moowar (unregistered) in reply to Wessel
    Wessel:
    Eek!
    Function In_(Of T As IComparable)(ByVal ParamArray values() As T) As Boolean
            If values.Length Mod 2 <> 0 Then Throw New ArgumentException()
    
            Dim q = From v In values _
                    Let index As Integer = Array.IndexOf(values, v) _
                    Where index = values.Count - 1 OrElse v.CompareTo(values(index + 1)) = 0
    
            Return q.Count() = values.Count()
        End Function
    

    Well it's still damn ugly :D

    They're not liked pairs, it's just checking if the others match the first one.

        Function In_(Of t As IComparable)(ByVal ParamArray values() As t) As Boolean
            If values.Length < 2 Then Exit Function
            Dim q = From v In values Let index As Integer = Array.IndexOf(values, v) Where index > 0
            Return Not (q.Count = (values.Count - 1))
        End Function
    

    linq will make same values share the same index, so if something matches (0), it will be omiited.

  • Tom (unregistered)

    Why not add some goto's too...

  • (cs)

    Note to the editor:

    It's slightly odd that the name of the software changes from CEE to ECC after the submitters' romp through the madness.

    :).

  • David (unregistered)

    Why not just the "Of" keyword

  • OBloodyhell (unregistered) in reply to Sean D
    Sean D:
    The real WTF is that he only has begin() and end(). Where's "middle()"? Or how about "keep_going()"?

    If you don't tell your code to keep running, it's just going to sit there doing nothing.

    My best guess is that it allowed him to drop in checkpoint and trace routines on demand without going straight to the code in question. Not saying that's the best way to do it, but, if the guy was a converted Microsoft Basic programmer, it may well have been a technique holdover from those days.

    Set a global variable, write an alteration to the begin() code which only printed out location and/or variable states when the global was set (multiple values, too, if you wanted to be more subtle), then run it. Voila. Code tracing and desired variable dumping made easy. The biggest flaw would be his lack of comments to that effect, so someone else would understand the otherwise absurd behavior.

  • _ (unregistered) in reply to Sean D

    This looks like generated code.

Leave a comment on “syntax.vb”

Log In or post as a guest

Replying to comment #:

« Return to Article