• TW (unregistered) in reply to just me
    just me:
    frits:
    Reading this article filled me with the urge to defecate.

    PFTFY

    FTFY

  • Oik (unregistered) in reply to vt_mruhlin

    Public Function makeBoolean(ByVal b As Boolean)

    if b is Boolean
    
        return b as Boolean
    
    else
    
        return FILENOTFOUND
    

    End Function

  • (cs) in reply to Bob
    Bob:
    Reminds me of the manager whose metric was a ratio of number of defects to lines of code. He offered a bonus to the programming staff if they could get the ratio below a certain threshold.

    The programming staff worked one weekend to attack the problem. They inserted blank lines between all lines of code; in effect, they cut the ratio in half.

    The manager was pleased with the result and convinced himself that he was a management genius.

    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!

    /*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ;; software_units.c                                        ;;
     ;;                                                         ;;
     ;; Description:                                            ;;
     ;;   Library of useless code that converts between types,  ;;
     ;;   that way we look more productive.                     ;;
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/

    But at least this manager realized the programmers were on to him. No more counting semicolons after that.

  • Anonymous (unregistered) in reply to Nagesh
    Nagesh:
    Not paid to argue

    Are you not having weekly defect prevent meetings, where you do peer review of code?

    Not paid to do QA. We have an entire department for that.

  • Meep (unregistered) in reply to vt_mruhlin
    vt_mruhlin:
    We can do better guys.
    Public Function makeBoolean(ByVal b As Boolean)
        if b is Boolean
            return b as Boolean
        else
            return null
    End Function

    (I don't actually know VB, so I might have mixed some c# in there, but who cares if it's valid syntax. It's more lines!)

    Amateurs. You're not checking for half the possible cases.

    Public Function makeBoolean(ByVal booleanPrimitive as Boolean)
        IBoolean booleanInterface = Factory.construct(CoercionClass.BooleanClass)
        Try
            If booleanPrimitive = True Then
                booleanInterface.setTrueValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive is True Then
                booleanInterface.setObjectTrueValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive <> True Then
                booleanInterface.setFalseValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive is Not True Then
                booleanInterface.setObjectFalseValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive = False Then
                booleanInterface.setFalseValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive is False Then
                booleanInterface.setObjectFalseValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive <> False Then
                booleanInterface.setTrueValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive is Not False Then
                booleanInterface.setObjectTrueValue(booleanPrimitive )
                return booleanInterface
            ElseIf booleanPrimitive is Null Then
                booleanInterface.setObjectNullValue(booleanPrimitive )
                return booleanInterface
            Else
                booleanInterface.setIndeterminateValue(booleanPrimitive )
                return booleanInterface
            End If
        On Error FileNotFoundError e
            booleanInterface.setFileNotFound(e)
            return booleanInterface
        End Try
    End Function makeBoolean
  • (cs)

    The generic version:

    Public Function MakeAnything(o)
    Return o
    End Function

  • (cs) in reply to Nagesh
    Nagesh:
    boog:
    Certainly you can't expect Marcus to point out the obvious asininity of this code in a formal peer review. He's sure to be labeled "that guy who hates on everyone else's code", and then he won't get invited to parties.

    Yep, better to keep his mouth shut.

    marcus should do job with complete and total dedication. maybe he rise up and above in organization.
    Who wants to promote the guy who makes you look bad?

    No, far better to be popular than be good at your job.

  • (cs) in reply to QJ
    QJ:
    boog:
    Certainly you can't expect Marcus to point out the obvious asininity of this code in a formal peer review. He's sure to be labeled "that guy who hates on everyone else's code", and then he won't get invited to parties.
    What you do is, you put your criticism in a sh*t sandwich.

    Nice tasty complimentary (and ultimately non-nourishing) piece-of-bread comment to start with "What wonderfully neatly laid out code this is! I approve!"

    Then give the sh*t: "... but surely we can accomplish this in an even more streamlined and enterprise-friendly manner by deleting the entire module."

    Then the nice tasty complimentary (and ultimately non-nourishing) piece-of-bread comment to end with: "And how wonderfully bug-free it seems to be - no doubt it passed all its unit tests? Can we see the unit tests?"

    You'll be rocketing up the promotion chain so fast you'll achieve escape velocity.

    That's genius. Well said.

  • (cs) in reply to Nagesh
    Nagesh:
    Not paid to argue

    Are you not having weekly defect prevent meetings, where you do peer review of code?

    Peer review is for people who can't be trusted to write excellent code on their own.

  • (cs)

    I see this as a failure of F#. If it was easier to grok, you wouldn't have so many horribad VB submissions. Instead, you'd get really funny attempts at "functional" programming.

  • (cs) in reply to frits
    frits:
    Reading this article caused me to make poo.

    Clearly the more elegant solution would account for all future needs:

    Public Function makeTypeObject(Of t)(ByVal arg As t)
        Return arg
    End Function
    
    
    YES! Although, this returns a T, not an Object as in the OP.

    Addendum (2011-04-21 11:09): Nevermind - it does return an object, since there is no "As T" at the end.

    I hate VB.

  • (cs) in reply to Andy
    Andy:
    In VB 6 this was the only way of doing casts, apart from creating another variable in the body of the code.
    Nope. VB6 had a number of built-in type conversion functions that are the equivalent of type casting. They include CInt, CStr, CCur, CDate, and others. They are much more limited than true type casting, but they were there and they cover all of the cases in the article.

    They are still there in VB.Net and are still better than the WTF in the article. Of course, VB.Net now has CType to expand the old pattern to support any type and DirectCast which is analogous to C style casting. CType is a little different from a traditional cast in that it will attempt to perform an implicit conversion if a cast is not possible (for example, integer to string).

  • (cs) in reply to boog
    boog:
    QJ:
    boog:
    Certainly you can't expect Marcus to point out the obvious asininity of this code in a formal peer review. He's sure to be labeled "that guy who hates on everyone else's code", and then he won't get invited to parties.
    What you do is, you put your criticism in a sh*t sandwich.

    Nice tasty complimentary (and ultimately non-nourishing) piece-of-bread comment to start with "What wonderfully neatly laid out code this is! I approve!"

    Then give the sh*t: "... but surely we can accomplish this in an even more streamlined and enterprise-friendly manner by deleting the entire module."

    Then the nice tasty complimentary (and ultimately non-nourishing) piece-of-bread comment to end with: "And how wonderfully bug-free it seems to be - no doubt it passed all its unit tests? Can we see the unit tests?"

    You'll be rocketing up the promotion chain so fast you'll achieve escape velocity.

    That's genius. Well said.

    It's usually called a "complement sandwich" and a well known passive-agressive management technique for delivering criticism. I think QJ's is much more acurate, since I would never expect a real sandwich to be named by its bread only.

  • herp (unregistered)

    This is obviously done for logging purposes.

    If you make sure that these functions are called for all variable initialisations and assignments, you can insert textfile logging into each function, thus ensuring that you have the best possible insight into why it runs so slow.

  • (cs) in reply to Power Troll
    Power Troll:
    I see this as a failure of F#. If it was easier to grok, you wouldn't have so many horribad VB submissions. Instead, you'd get really funny attempts at "functional" programming.

    This is troll comment example I always tell people. If all programming in the world took place in java, we would be better off 100 times than before.

  • (cs) in reply to QJ
    QJ:
    boog:
    Nagesh:
    Not paid to argue

    Are you not having weekly defect prevent meetings, where you do peer review of code?

    Certainly you can't expect Marcus to point out the obvious asininity of this code in a formal peer review. He's sure to be labeled "that guy who hates on everyone else's code", and then he won't get invited to parties.

    Yep, better to keep his mouth shut.

    What you do is, you put your criticism in a sh*t sandwich.

    Nice tasty complimentary (and ultimately non-nourishing) piece-of-bread comment to start with "What wonderfully neatly laid out code this is! I approve!"

    Then give the sh*t: "... but surely we can accomplish this in an even more streamlined and enterprise-friendly manner by deleting the entire module."

    Then the nice tasty complimentary (and ultimately non-nourishing) piece-of-bread comment to end with: "And how wonderfully bug-free it seems to be - no doubt it passed all its unit tests? Can we see the unit tests?"

    You'll be rocketing up the promotion chain so fast you'll achieve escape velocity.

    Excellent comment. I make note of this!

  • iToad (unregistered) in reply to frits
    frits:
    Reading this article caused me to make poo.

    Clearly the more elegant solution would account for all future needs:

    Public Function makeTypeObject(Of t)(ByVal arg As t)
        Return arg
    End Function
    
    

    We have reviewed your units of software count for the previous month. Unfortunately, although your units of software are elegant and correct, your count is less than the units of software count of your peers. Therefore, this company no longer requires your services.

  • (cs) in reply to Nagesh
    Nagesh:
    Power Troll:
    I see this as a failure of F#. If it was easier to grok, you wouldn't have so many horribad VB submissions. Instead, you'd get really funny attempts at "functional" programming.

    This is troll comment example I always tell people. If all programming in the world took place in java, we would be better off 100 times than before.

    It's hard to understand what you mean, but if you actually mean that the world would be better of if everything were written in Java, then you are insane.
  • (cs) in reply to hoodaticus
    hoodaticus:
    Nagesh:
    Power Troll:
    I see this as a failure of F#. If it was easier to grok, you wouldn't have so many horribad VB submissions. Instead, you'd get really funny attempts at "functional" programming.

    This is troll comment example I always tell people. If all programming in the world took place in java, we would be better off 100 times than before.

    It's hard to understand what you mean, but if you actually mean that the world would be better of if everything were written in Java, then you are insane.

    I made troll comment and you're first bite.

  • Wonk (unregistered)

    Obligatory askimet bait:

    http://www.youtube.com/watch?v=ewIT_KAQQlU&feature=related

  • (cs) in reply to Nagesh
    Nagesh:
    hoodaticus:
    Nagesh:
    Power Troll:
    I see this as a failure of F#. If it was easier to grok, you wouldn't have so many horribad VB submissions. Instead, you'd get really funny attempts at "functional" programming.

    This is troll comment example I always tell people. If all programming in the world took place in java, we would be better off 100 times than before.

    It's hard to understand what you mean, but if you actually mean that the world would be better of if everything were written in Java, then you are insane.

    I made troll comment and you're first bite.

    Your parents must be so proud.

  • Complement Sandwich (unregistered) in reply to Nagesh
    Nagesh:
    hoodaticus:
    Nagesh:
    Power Troll:
    I see this as a failure of F#. If it was easier to grok, you wouldn't have so many horribad VB submissions. Instead, you'd get really funny attempts at "functional" programming.

    This is troll comment example I always tell people. If all programming in the world took place in java, we would be better off 100 times than before.

    It's hard to understand what you mean, but if you actually mean that the world would be better of if everything were written in Java, then you are insane.

    I made troll comment and you're first bite.

    Your ability to troll is, without a doubt, exquisite.

    Unfortunately, not a single person finds your tired act funny. For some special people, it's just a little more difficult illicit laughter from others. This is OK.

    I can tell by the number comments you make that you are a very hard worker. I believe that if you applied yourself, you could achieve anything.

  • riiiiiiight (unregistered)

    Okay, I think we can establish now for sure that hoodactius and nagesh are the same person.

  • (cs) in reply to boog
    boog:
    Bob:
    Reminds me of the manager whose metric was a ratio of number of defects to lines of code. He offered a bonus to the programming staff if they could get the ratio below a certain threshold.

    The programming staff worked one weekend to attack the problem. They inserted blank lines between all lines of code; in effect, they cut the ratio in half.

    The manager was pleased with the result and convinced himself that he was a management genius.

    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!

    /*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ;; software_units.c                                        ;;
     ;;                                                         ;;
     ;; Description:                                            ;;
     ;;   Library of useless code that converts between types,  ;;
     ;;   that way we look more productive.                     ;;
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/

    But at least this manager realized the programmers were on to him. No more counting semicolons after that.

    Hrm. Maybe a different approach needs to be taken:

    1. Strip out all comments.
    2. Strip out all new lines.
    3. Insert new lines after opening and closing curly braces.
    4. Insert new lines after every semi-colon.
    5. Strip out all semi-colons.
    6. Count lines.
  • (cs) in reply to riiiiiiight
    riiiiiiight:
    Okay, I think we can establish now for sure that hoodactius and nagesh are the same person.

    Wow!

  • (cs) in reply to dohpaz42
    dohpaz42:
    Hrm. Maybe a different approach needs to be taken:
    1. Strip out all comments.
    2. Strip out all new lines.
    3. Insert new lines after opening and closing curly braces.
    4. Insert new lines after every semi-colon.
    5. Strip out all semi-colons.
    6. Count lines.
    • Remember not to do this on the live file.
  • Joey Alcorn (unregistered)
    Public Function makeBrainExplode(ByVal b As Brain)
        Throw New AneurysmException
    End Function
    
  • (cs) in reply to Stevie D
    Stevie D:
    dohpaz42:
    Hrm. Maybe a different approach needs to be taken:
    1. Strip out all comments.
    2. Strip out all new lines.
    3. Insert new lines after opening and closing curly braces.
    4. Insert new lines after every semi-colon.
    5. Strip out all semi-colons.
    6. Count lines.
  • Remember not to do this on the live file.
  • You know, that is actually a very valid point. I once interviewed for a company that had absolutely no development environment. In fact, all of their developers (there were more than 5 at the time) would work on production files. When I asked if it were permissible to install and work off of a development environment (i.e., on the local work station), I was scoffed at as if this was some crazy idea. Thankfully, I never did get that job.

  • (cs) in reply to Nagesh
    Nagesh:
    riiiiiiight:
    Okay, I think we can establish now for sure that hoodactius and nagesh are the same person.

    Wow!

    Eww. Low blow bro!

    At least I know the difference between C++ and SQL.

  • Design Pattern (unregistered) in reply to Nagesh

    50 % of your comment (line count) is redundant!

    Nagesh:
    This is troll comment example
    This was already clear when we read the line:
    2011-04-21 11:09 • by Nagesh
    Nagesh:
    I always tell people. If all programming in the world took place in java, we would be better off 100 times than before.
    If all programming in the world took place in Java, then you would not try to counterfeit an indian programmer.

    Your not so smart, are you?

  • Meep (unregistered) in reply to riiiiiiight
    riiiiiiiiiiiiiiiiiiiight:
    Okay, I think we can establish now for sure that hoodactius and nagesh are the same person.

    I'm not so sure, I thought they were life partners. The real question is which one is the top and which is the bottom?

  • (cs) in reply to Meep
    Meep:
    riiiiiiiiiiiiiiiiiiiight:
    Okay, I think we can establish now for sure that hoodactius and nagesh are the same person.

    I'm not so sure, I thought they were life partners. The real question is which one is the top and which is the bottom?

    My heart will always belong to Morbius Wilters.

  • (cs) in reply to hoodaticus
    hoodaticus:
    Meep:
    riiiiiiiiiiiiiiiiiiiight:
    Okay, I think we can establish now for sure that hoodactius and nagesh are the same person.

    I'm not so sure, I thought they were life partners. The real question is which one is the top and which is the bottom?

    My heart will always belong to Morbius Wilters.
    I thought he was an Asian chick.

    Anyway, are we allowed to talk about him here?

  • Ken B. (unregistered) in reply to boog
    boog:
    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!
    Aha! More proof that "for(;;)" is more productive than "while(1)".
  • Ken B. (unregistered)

    I, personally, am offended by the "makeUShort()" function.

    And I get enough spam apparently generated by the "makeULong()" function.

  • (cs) in reply to Ken B.
    Ken B.:
    boog:
    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!
    Aha! More proof that "for(;;)" is more productive than "while(1)".
    Indeed. By exactly 2 units of productivity.
  • Ken B. (unregistered) in reply to dohpaz42
    dohpaz42:
    boog:
    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!
    /*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ;; software_units.c                                        ;;
     ;;                                                         ;;
     ;; Description:                                            ;;
     ;;   Library of useless code that converts between types,  ;;
     ;;   that way we look more productive.                     ;;
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
    But at least this manager realized the programmers were on to him. No more counting semicolons after that.

    Hrm. Maybe a different approach needs to be taken:

    1. Strip out all comments.
    2. Strip out all new lines.
    3. Insert new lines after opening and closing curly braces.
    4. Insert new lines after every semi-colon.
    5. Strip out all semi-colons.
    6. Count lines.
    A semicolon is a perfectly valid statement on its own.
    ;;;;;;;;;; /* Define "a" */ ;;;;;;;;;;
    int a;
    ;;;;;;;;;; /* Define "b" */ ;;;;;;;;;;
    int b;
    ;;;;;;;;;; /* Define "c" */ ;;;;;;;;;;
    int c;
  • (cs) in reply to dohpaz42
    dohpaz42:
    boog:
    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!
    Hrm. Maybe a different approach needs to be taken:
    1. Strip out all comments.
    2. Strip out all new lines.
    3. Insert new lines after opening and closing curly braces.
    4. Insert new lines after every semi-colon.
    5. Strip out all semi-colons.
    6. Count lines.
    {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
      printf("I'm ");;;;;;;;;;;;;;;;;;;;
      printf("sure ");;;;;;;;;;;;;;;;;;;;
      printf("you're ");;;;;;;;;;;;;;;;;;;;
      printf("joking.\n");;;;;;;;;;;;;;;;;;;;
      printf("This ");;;;;;;;;;;;;;;;;;;;
      printf("is ");;;;;;;;;;;;;;;;;;;;
      printf("valid ");;;;;;;;;;;;;;;;;;;;
      printf("C.\n");;;;;;;;;;;;;;;;;;;;
    }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  • Rictor (unregistered) in reply to Complement Sandwich

    This comment made me laugh so hard I got a few funny looks.

  • trtrwtf (unregistered) in reply to SCSimmons
    SCSimmons:
    The manager doesn't need to know that the 60 hours of overtime he paid out was 2 minutes of writing replace scripts and 59 hours and 58 minutes of playing Quake.

    And drinking beer, drinking beer is very important when you're padding out company time.

  • Patrick (unregistered)

    If you delete a 2MB file of bad code, does that count negatively on your production?

    "Well, I'm pleased you got that entire project finished in one week, but unfortunately it says here that you only wrote four lines of code." "... well, that's..." "In one week. Do you know how much code the other members of our 'TEAM' write in a week?" "But they..." "And this project only took four lines, I mean what were you doing the rest of the time? Should I have doubts about the other estimates you give me?"

  • silent d (unregistered) in reply to Nagesh
    Nagesh:
    Not paid to argue

    Are you not having weekly defect prevent meetings, where you do peer review of code?

    If you want me to go on arguing, you'll have to pay for another five minutes.

  • Bubba (unregistered)

    MakeFloat is missing.

  • Rob (unregistered) in reply to Anon
    Anon:
    I know very little about VB / VB.NET, so could someone explain how this isn't largely equivalent to a) casting (e.g. (unsigned long) x); or b) forcing a type for an integer literal (e.g. 42lu); in C?

    The idea might be similar but (from what I understand) this approach is really just silly wasted lines of code.

    Depending on the types and your compiler setting, VB.Net will either allow an implicit conversion (in which case you wouldn't need to call any of these make* functions, the compiler would just let you use a double as an integer without calling makeInteger(myDouble). )

    In the situation where the compiler will not allow it (either because of Option Explicit being set on or because the types don't support it), you'd need an explicit conversion. So, your call to makeInteger would have to take an Integer as input.

    The code would end up looking like this....

    Dim myDouble as Double Dim myInt as Integer

    myInt = makeInteger(Ctype(myDouble, Integer))

    When you could just do

    myInt = Ctype(myDouble, Integer)

    And in the implicit case; instead of

    myInt = makeInteger(myDouble)

    You could do

    myInt = myDouble

    Some people would argue that the last example is an invitation for bugs. But they'd probably tell you to turn Option Explicit on and the compiler would disallow it, or, if you want the code to be more readable, use the built-in conversion options CType or CInt()

    If I'm understanding it correctly, it's just extra code that doesn't really accomplish anything. The person who wrote was either trying to inflate the line count/function count or (more likely in my opinion) wanted to avoid the implicit conversion and felt that his or her helper functions made things 'more clear'.

    Of course, it wouldn't be the first time that I've completely missed the WTF.

  • Herby (unregistered)

    Lines of code measurements never heard of writing in APL (Iverson, c1963). There you could do a WHOLE project in one line and take DAYS doing it. Even more time debugging it as well.

    If you want a metric, try counting parenthesis in Lisp (Scheme), it gets quite a ratio!

    The only true way of doing reasonable metrics (which are useless anyway) is wiring them into the compiler. It has to unwind all the junk people write anyway, so it has a better idea of what is going on.

  • (cs) in reply to Rob
    Rob:
    Anon:
    I know very little about VB / VB.NET, so could someone explain how this isn't largely equivalent to a) casting (e.g. (unsigned long) x); or b) forcing a type for an integer literal (e.g. 42lu); in C?

    The idea might be similar but (from what I understand) this approach is really just silly wasted lines of code.

    Depending on the types and your compiler setting, VB.Net will either allow an implicit conversion (in which case you wouldn't need to call any of these make* functions, the compiler would just let you use a double as an integer without calling makeInteger(myDouble). )

    In the situation where the compiler will not allow it (either because of Option Explicit being set on or because the types don't support it), you'd need an explicit conversion. So, your call to makeInteger would have to take an Integer as input.

    The code would end up looking like this....

    Dim myDouble as Double Dim myInt as Integer

    myInt = makeInteger(Ctype(myDouble, Integer))

    When you could just do

    myInt = Ctype(myDouble, Integer)

    And in the implicit case; instead of

    myInt = makeInteger(myDouble)

    You could do

    myInt = myDouble

    Some people would argue that the last example is an invitation for bugs. But they'd probably tell you to turn Option Explicit on and the compiler would disallow it, or, if you want the code to be more readable, use the built-in conversion options CType or CInt()

    If I'm understanding it correctly, it's just extra code that doesn't really accomplish anything. The person who wrote was either trying to inflate the line count/function count or (more likely in my opinion) wanted to avoid the implicit conversion and felt that his or her helper functions made things 'more clear'.

    Of course, it wouldn't be the first time that I've completely missed the WTF.

    Unfortunately, this code might actually do something. For example, you could use makeInteger to round a Variant to the nearest even whole number.

    Dim a a = 4.9 Dim b b = makeInteger(a)

  • BrMcMullin (unregistered) in reply to Bumble Bee Tuna
    Bumble Bee Tuna:
    I get emails advertising that makeULong function every day. It must be good code.

    ISWYDT...

  • F (unregistered) in reply to frits
    frits:
    Reading this article caused me to make poo.

    Clearly the more elegant solution would account for all future needs:

    Public Function makeTypeObject(Of t)(ByVal arg As t)
        Return arg
    End Function
    
    

    It completely fails to account for the need to turn in large amounts of code in order to satisfy management's inane metrics (and thereby get paid / promoted)

  • Anonymous Coward (unregistered) in reply to Bumble Bee Tuna

    In that context, I shudder to think what the makeUShort would entail.

  • (cs) in reply to boog
    boog:
    dohpaz42:
    boog:
    I heard a similar story once where a "smart" manager realized that LOC was a poor metric and came up with the brillant idea to secretly write a script that counts semicolons (in C) as a measurement of productivity. The programmers eventually realized he was doing this and started using semicolons as comment formatting. Productivity skyrocketed!
    Hrm. Maybe a different approach needs to be taken:
    1. Strip out all comments.
    2. Strip out all new lines.
    3. Insert new lines after opening and closing curly braces.
    4. Insert new lines after every semi-colon.
    5. Strip out all semi-colons.
    6. Count lines.
    {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
      printf("I'm ");;;;;;;;;;;;;;;;;;;;
      printf("sure ");;;;;;;;;;;;;;;;;;;;
      printf("you're ");;;;;;;;;;;;;;;;;;;;
      printf("joking.\n");;;;;;;;;;;;;;;;;;;;
      printf("This ");;;;;;;;;;;;;;;;;;;;
      printf("is ");;;;;;;;;;;;;;;;;;;;
      printf("valid ");;;;;;;;;;;;;;;;;;;;
      printf("C.\n");;;;;;;;;;;;;;;;;;;;
    }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    It has nothing to do with the validity of code; I was simply thinking of a different way to count lines of code - with respect to developers trying to game the system by adding useless semi-colons and whitespace, etc.

Leave a comment on “Units of Software”

Log In or post as a guest

Replying to comment #:

« Return to Article