• henke37 (cs)

    makeString2 is indeed redundant.

  • XXXXX (unregistered)

    If you measure software in the number of Pieces Of Software (POS) that's exactly what you get.

  • Anon Too (unregistered)

    Are you kidding me? WTF!

  • Your Name (unregistered)

    You start paying by the line, you're gonna get more lines. What do you expect?

  • Machtyn (unregistered)

    Are you seriously trying to pass this off as production code? That's first week of first semester of programming class mistakes (for those that have never looked at code prior to taking the class).

  • Some guy (unregistered) in reply to henke37
    henke37:
    makeString2 is indeed redundant.
    It uses a completely different code path!
  • Pete (unregistered)

    The optimist in me says this is fake, no one could possibly do this.

    The realist says I have met people capable of this.

  • frits (cs)

    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
    
    
  • Bob (unregistered)

    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.

  • vt_mruhlin (unregistered)

    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!)

  • Nagesh (cs)

    Not paid to argue

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

  • Dan (unregistered) 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.

    If the policy resulted in programmers actually commenting their code that would have been genius (provided they were real comments).

  • Bas (unregistered)

    Clearly Visual Basic does implicit type casting for such calls, and this is just a weirdly convoluted way of explicit type casting.

  • Keith (unregistered)

    It is possible that the functions listed here are for the explicit purpose of creating new references, though it wouldn't be required for the value types and it would not work properly for the strings (due to interment).

  • Bill's Kid (unregistered)

    I don't know, the MakeULong function might be useful. If it really works, that is.

  • anon (unregistered) 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.

    If it takes a team of programmers an entire weekend to add blank lines to their code, they're probably not the greatest programmers. Also, I know of nothing that includes blank lines when counting LoC. So basically, I'm pretty sure your story is bullshit.

  • Bumble Bee Tuna (cs)

    I get emails advertising that makeULong function every day. It must be good code.

  • Larrik (unregistered) 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.

    It took a whole weekend to add line breaks to the source code? Now THAT is a WTF!

  • Menno (unregistered)

    Shouldn't those be static functions? I think that's "Shared" in vb.

  • Larrik (unregistered) in reply to anon
    anon:

    If it takes a team of programmers an entire weekend to add blank lines to their code, they're probably not the greatest programmers. Also, I know of nothing that includes blank lines when counting LoC. So basically, I'm pretty sure your story is bullshit.

    That's easy, don't count LoC. Just count line breaks. I'm sure it'd easy to get that past this "manager".

  • m (unregistered) in reply to anon

    what about this instead of empty lines (added benefit: it makes the program run for longer, so it must be doing mode things, mustn't it!):

    system ('echo "$random_string" >/dev/null');

    captcha: genitus (genial I knew it..)

  • akatherder (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?

    Yes. Yes we are not having those.

  • anonymouser (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?

    I work with a bunch of Indian contractors; so, I have no peers.

  • Option Strict, Please (unregistered) in reply to Bas
    Bas:
    Clearly Visual Basic does implicit type casting for such calls, and this is just a weirdly convoluted way of explicit type casting.

    Except that the return from all of these functions is of type Object

  • blarg (unregistered)

    Public Function makeFristComment(ByVal u As Comment) Return frist End Function

    Public Function makeRegularComment(ByVal u As Comment) Return embededSystem End Function

  • pussywhipped (unregistered) 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 think I'm going to cry.

  • Le Forgeron (unregistered)

    Assert#1: in C, LoC is measured by ";". Rule #2: ";" by itself is a no-op. Silly Target: double number of LoC.

    Solution:

    1. duplicate each ";" which ends a LoC (beware of actual ";" in text)
    2. ...
    3. Profit
  • gogol (unregistered) in reply to vt_mruhlin

    fixed

    Public Function makeBoolean(ByVal b As Boolean)
        if b is Boolean
            return b as Boolean
        else
            return Boolean.FILE_NOT_FOUND
    End Function
    
  • HonoreDB (cs)

    These would get more effective (or possibly break everything forever if) you moved the right parenthesis a bit leftward.

  • pussywhipped (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?

    As a peer reviewer, I am a peer. I will prove it by peeing all over it.

  • blarg (unregistered) 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.

    It took them a whole weekend to do something which a s/\n/\n\n/ style regex could have done in seconds?

    Regardless.. the issue you highlight is exactly why people start using function point counts rather than line counts for their metrics, and this in turn is what drives people to do things such as this particular WTF

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

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

    Yes. Yes we are not having those.

    No wonder poor quality of code.

  • Andy (unregistered)

    In VB 6 this was the only way of doing casts, apart from creating another variable in the body of the code.

  • QJ (unregistered)

    It's a bit like a piece of serial music.

    It goes: "diddle-diddle-diddle-diddle-diddle-diddle-diddle-diddle-diddle ..." for ages, then suddenly does: "diddle-diddle-doodle-diddle ..." and then goes back to "diddle-diddle-diddle-diddle ..."

    Utter genius.

  • SCSimmons (cs) in reply to blarg
    blarg:
    It took them a whole weekend to do something which a s/\n/\n\n/ style regex could have done in seconds?
    If you do it in seconds, the manager will get suspicious of the huge improvement in the metric and start digging for details. If you bring the whole department in to work on it for the weekend, the 50% reduction in errors per line looks at least plausible. 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.
  • QJ (unregistered) 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.

    The real WTF is that there are known defects in the code which are not being addressed. You can drastically reduce the number of defects in the code by fixing them when they come to light. Call me boring and old-fashioned but if (as that manager) I were to find what had been done (and if it were me, I would) then heads would roll. Granted, I would not use this metric in the first place, but that's not the point.

  • szeryf (unregistered)

    I love makeString2 :)

  • Wonk (unregistered)

    Someone told me this WTF had a cast of thousands.....I had no idea.

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

    There, I Pink Floyded that for you...

  • Your Name (unregistered) in reply to QJ
    QJ:
    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.

    The real WTF is that there are known defects in the code which are not being addressed. You can drastically reduce the number of defects in the code by fixing them when they come to light. Call me boring and old-fashioned but if (as that manager) I were to find what had been done (and if it were me, I would) then heads would roll. Granted, I would not use this metric in the first place, but that's not the point.

    No, that is the point. If you are the sort of manager that uses useless metrics of the "defects per KSLOC" sort, you are likely also the sort of manager who won't look too closely (or even know how to look) at what your reports did to meet your useless metric.

  • boog (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?

    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.

  • Lockwood (cs)

    DirectCast()

    Frist time I've been hit by Akismet. Am I now "one of the guys"?

  • Nagesh (cs) in reply to boog
    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.

    marcus should do job with complete and total dedication. maybe he rise up and above in organization.

  • Rodnas (unregistered)

    Everyone knows that more lines of code makes the software better, more stable and faster and more maintainable and ... well it is just better, Okay!

  • Nagesh (cs) in reply to Lockwood
    Lockwood:
    DirectCast()

    Frist time I've been hit by Akismet. Am I now "one of the guys"?

    Akismet love to hit me daily. In every post I make, I offer a small sacrificial post to Akismet.

  • Nagesh (cs) in reply to Rodnas
    Rodnas:
    Everyone knows that more lines of code makes the software better, more stable and faster and more maintainable and ... well it is just better, Okay!

    Love sarcasm comment here.

  • Uncle Al (unregistered)

    This reminds me of a story from a former boss. In his days working for a large defense contractor, management followed the well trodden, broad path (and we all remember where that path paved with good intentions leads, right? :-) ) to counting lines of code. However, they wanted to add a level of sophistication to the count. Since:

     
    if (a) { b; } 
    

    and

     
    if (a)
    {
       b;
    }
    

    are equivalent modulo formatting, they wanted to find a LOC metric that considered those equivalent. The method they hit on was counting semicolons (since this was C).

    Subsequently, the development team's productivity soared... until the first external code review, which revealed that statements like the above had been replaced by the syntactically correct:

     
    if (a) { b;; } 
    

    So much for that metric.

  • QJ (unregistered) in reply to boog
    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.

  • Anon (unregistered)

    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?

  • cheap nfl trolls (unregistered) in reply to Nagesh
    Nagesh:
    Akismet love to hit me daily. In every post I make, I offer a small sacrificial post to Akismet.
    For this comment, inspired me, feeling this author words into my heart.

Leave a comment on “Units of Software”

Log In or post as a guest

Replying to comment #:

« Return to Article