• (cs) in reply to Spewin Coffee
    Spewin Coffee:
    Interestingly, I can generally identify bad programmers a mile away by how poorly they use whitespace, where they place their comments, variable and function names, and the content of the comments.
    So where do bad programmers place their comments?
  • (cs) in reply to Spewin Coffee

    :p EBiggotry is the 2nd biggest activity on the daily wtf... though I wish it would go away.

    I should point out (however) that Bob's comment was somewhat ambiguous... and he was not necessarily saying what you seem to have taken away from that message. I read it as (the quality of php is fully subject to the quality of the developer, unlike most other languages).. which I take to mean that PHP has a significant number of options that are unusual to find in programming languages (which is true) and bad programmers tend to be inconsistent. Inconsistency with php makes a much bigger mess than it does with more rigid languages.

    That said... I disagree with your comment about "the right way". In the programming world, "the right way" is an amorphis ideal that is given form only by the collection of individuals who interact with it and the competence with which the technology is leveraged. Coupled with consistency and adherance to more publically accepted standards, there are still a hundred paths to the same door (as it were).

    Still... I stand behind my previous comments that the programming language of choice for a developer says about as much about their competance, intelligence and ability as their height and eye color.

  • (cs) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    Spewin Coffee:
    Interestingly, I can generally identify bad programmers a mile away by how poorly they use whitespace, where they place their comments, variable and function names, and the content of the comments.
    So where do bad programmers place their comments?

    // TODO: Place a comment here.

  • AE (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    C'mon... Everyone knows you use x, y, z, and sometimes a as generic counters.

    Ah but by just using one letter repeated multiple times he can change the naming convention for all counters across the board by Find and Replace 'n'. Really it's very foresighted.

  • Unisol (unregistered)

    Goddamn it, Remy, I come here to see unicorns and now you're dissapointing me.

  • Kasper (unregistered) in reply to Bob
    Bob:
    I don't get the COBOL reference.
    And I have never touched COBOL, so I don't get it either. But could it have something to do with the way he is passing parameters to a function through global variables?

    (CAPTCHA: vindico. I didn't even have to type it all, as my browser could remember it from last time I got the same.)

  • Old fart (unregistered)

    A "real" COBOL fanatic would have used thirty-two character variable names, at the least. Longer if the eighty-character punched cards had additional space before column seventy-two.

    Ask me how I know.

  • Daniel (unregistered) in reply to Bob

    The "COBOL" was the self-professed skill of the original author. That's the reference. Also, if you've done any COBOL, the block of declaration at the top is eerily reminiscent of the WORKING-STORAGE SECTION. Heck, at least this one is actually in the function!

    But, even in COBOL, this is crappy COBOL; to determine an FY, you just need the cut-off date. Then, a quick comparison of the month in numeric format will render an easy answer (the year, or the year plus one). An up-to-20-iteration loop to figure that out? Just because the cycles are quick doesn't mean we should use more than we need. :)

    To me, this illustrates perfectly the adage that "you can code crappy COBOL in any language".

  • SG_01 (unregistered)
    stryear2 = stryear2 - 1
    Can someone tell me what this is even supposed to do? Remove a 1 character from the string or somesuch?

    "abcdefg" - 1 does not make much sense to me.

  • (cs) in reply to PedanticCurmudgeon
    AE:
    PiisAWheeL:
    C'mon... Everyone knows you use x, y, z, and sometimes a as generic counters.
    Ah but by just using one letter repeated multiple times he can change the naming convention for all counters across the board by Find and Replace 'n'. Really it's very foresighted.
    Whats wrong with find and replace 'x'. Your keyboard missing the "x" key?
    PedanticCurmudgeon:
    Spewin Coffee:
    Interestingly, I can generally identify bad programmers a mile away by how poorly they use whitespace, where they place their comments, variable and function names, and the content of the comments.
    So where do bad programmers place their comments?
    I want to play. I'll tell you where I place my comments and you tell me, on a scale of 1-10, where I stand. I put my "Explain what the function does" comment right above the function. I put all my "block explaination" comments right above the if/while/whatever statement. My "individual line" comments (when required) are either at the end of the line in question or right above it.
    //This function bla bla bla
    function func_name(x,y,and,z)
    {
      //someshit deals with someshit
      if (x >= wtfery)
      {
        //something not obvious or complicated
        x++; //Sometimes i put something not obvious or complicated here.
      }
      ...
    }
    

    How'd I do?

  • (cs) in reply to SG_01
    SG_01:
    stryear2 = stryear2 - 1
    Can someone tell me what this is even supposed to do? Remove a 1 character from the string or somesuch?

    "abcdefg" - 1 does not make much sense to me.

    My best guess (without context of the global variable) is that the variable is the current year, and we are subtracting to get last year, so we can fiscally balance between then and the current year. Does it work? I don't know.
  • (cs) in reply to Unisol
    Unisol:
    Goddamn it, Remy, I come here to see unicorns and now you're dissapointing me.
    Then go visit www.comeheretoseeunicorns.com.
  • Cbuttius (unregistered)

    Does it work? Does it do what it is supposed to do?

    I am not sure what it means to subtract 1 from a string. I am surprised that compiles, even in VB.

  • Cbuttius (unregistered)

    except of course I forgot:

    it makes no sense. It doesn't compile. It doesn't work with any business logic. And it doesn't exist. It's a made up WTF as usual.

  • AGray (unregistered)

    So, I counted some WTFs in this snippet:

    1: Variables. nn, nnn, nnnn are not used in any way. All the names are undescriptive. strYear2 could have just been passed into this function (bonus points would have been given for effort if it was abbreviated, but descriptive, for instance 'curFiscalYr'.)

    2: Execution n = 20 ... Do Until n = 0 ... n = n - 1 ... Loop is a For loop that should have happened, but did not. :( Date2 and Date3 should be defined and used within the loop. Oh, and named something that makes sense, without performing mental mapping.

    CAPTCHA: tristique - This code has a certain 'tristique'...ok, that sounded cooler in my head.

  • rfoxmich (unregistered)

    I don't get it. Where are the PICTURE clauses?

  • (cs) in reply to PiisAWheeL
    PiisAWheeL:
    Dim n As Integer Dim nn As Integer Dim nnn As Integer Dim nnnn As Integer
    C'mon... Everyone knows you use x, y, z, and sometimes a as generic counters.
    Ever since the days of BASIC (where spaces were not significant), I always used i, j and k. That way, if you are ever tempted to write a triply-nested loop, you find yourself writing "FORK=....".

    Which reminds you that you have indeed forked up.

  • (cs)

    '' VB.NET public Function FiscalYear(dateItem As DateTime) return IIF( dateItem.Month > 6, dateItem.Year +1, dateItem.Year ) End Function

    ''' Call with FiscalYear(DateTime.Now).ToString() to get string version

    '' VB6 Function FiscalYear(dateItem As Date) FiscalYear = IIF( dateItem.Month > 6, dateItem.Year +1, dateItem.Year ) end Function '' call with cstr(FiscalYear(Now()))

    ''' THE REAL WTFs.... why return a string to represent an int? And this role can be performed with one line of code.

  • Z (unregistered)

    A new software developed in VB6 by a COBOL programmer... what can possibly go wrong?

  • soei (unregistered)

    Oh, I get it....nn, nnn and nnnn are never used? Or is it that they break the convention used for other variables, and should have been n1, n2, n3, n4 ?

  • Jim (unregistered) in reply to RichP
    RichP:
    Um no, you use i, j, k and sometimes m as generic counters.

    (cue religious war akin to camelCase versus name_with_underscore)

    in CS101 they taught me to use meaningful names. I have: counter, loopCounter, iter, count and a plethora of others... Of course, to avoid a massive increase in typing, I still use i and then find-replace all i's with count.

    on a totally unrelated note, I found some serious issues in a program I inherited the other day. I don't even know how it compiled for my predecessor:

    publcountc countnt macountn(vocountd)
    {
      for(count=0; count<1000; count++)
      {
        countf(count%5 == 0)
        {
          System.out.prcountntln(count + "counts Dcountvcountscountble by fcountve");
        }
      }
    }
    
  • wooly (unregistered) in reply to Spewin Coffee
    Spewin Coffee:
    TRWTF is your incredibly false assumption that PHP is a bad language and all programmers who write in PHP are writing bad code. I will agree with anyone that says that PHP makes it easy to write bad code because you can do the same thing about 25 different ways of which only two of those ways is correct. Although, the same can be said of C++ and other languages that hand you powerful tools to work with. In the hands of a novice, you get crap output for both of the languages I mentioned because it takes years to master which of the 25 different ways to accomplish a task is the correct approach.

    There are many bad languages (APL, Prolog, LISP, COBOL, any assembly language, Ruby without Rails, etc.) and many bad programmers - the latter are what this site is dedicated to exposing to the world. Worse Than Fails happen any time you mix the two. If you think otherwise, you haven't been programming as long as I have. Interestingly, I can generally identify bad programmers a mile away by how poorly they use whitespace, where they place their comments, variable and function names, and the content of the comments. Basically, is the code elegant or not? That tells me more about their coding and personal habits (including hygiene) than anything else.

    Your inane comment, Bob, indicates you might be a bad programmer. Or at least clueless.

    I agree with some of this.

    Bad programmers can make any language look bad - and unfortunately a language that forced people to be good programmers wouldn't be very useful...(that's the job of the tertiary educators).

    Coding Style speaks volumes, partly because you can see whether the mindset is thinking maintainability, partly because you can really see whether someone understands (or conversely has copied StackOverflow) based on the structure and commenting and partly (tying back into point 1) someone who structures code readably has probably learnt (likely the hard way) that they will need to be able to find bugs in it later.

    Interestingly, you can often even pick the dick who thinks he's clever (and may be) by writing (possibly unintentionally) obfuscated code vs the dick who has no clue to what he's doing....

  • wooly (unregistered) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    Spewin Coffee:
    Interestingly, I can generally identify bad programmers a mile away by how poorly they use whitespace, where they place their comments, variable and function names, and the content of the comments.
    So where do bad programmers place their comments?
    on TDWTF of course....
  • ok (unregistered) in reply to Old fart
    Old fart:
    A "real" COBOL fanatic would have used thirty-two character variable names, at the least. Longer if the eighty-character punched cards had additional space before column seventy-two.

    Ask me how I know.

    How do you know?

  • (cs) in reply to Soviut

    I code every language like I'm programming LISP. Or, worded another way, (like (code (languages)) LISP).

  • Gary Olson (unregistered)
    Dim date1 As Date Dim date2 As Date Dim date3 As Date
    Yes, I've met these 3 ladies. Thank God for beer.
  • Meep (unregistered) in reply to Remy Porter
    Remy Porter:
    I used to do a lot of training. A big part of my job was teaching state employees, who had done COBOL for longer than I had been alive, to do Java, C++ and .NET (not all at the same time). It's not COBOL that's a problem, but COBOL programmers are built into their habits. The idea of modeling an application as a collection of things and not a collection of steps is a really hard thing to grasp if you have 30 years of practice working the other way.

    Seems more like the problem is the blind are leading the blind.

  • Ken (unregistered) in reply to Bob

    I am not biased I have 10 years of cobol under my belt and worked on the programming standard for cobol.

    Cobol is a globally scoped programming language and while you can call other modules from one source to another and have good scoping rules it is universally never taught and frowned upon by the top coders. For any serious cobol program it is a minimum of 10,000 lines with declarations at the top and a hopefully a naming and grouping standard to keep them grouped for to you make sense of it.

    While the language is not universally bad as a rule of thumb the application of it is.

    I have taught new languages a few cobol coders in my time and it is always 'interesting' at first as they learn for the first time to modularise.

  • Meep (unregistered) in reply to Spewin Coffee
    Spewin Coffee:
    TRWTF is your incredibly false assumption that PHP is a bad language and all programmers who write in PHP are writing bad code.

    Except that the reason certain features were changed in PHP was that they were security holes.

    Everyone who was writing to the spec was writing bad code. When they disallowed those constructs, they forced everyone to write better code.

    So are you going to argue that PHP 4 is just as good as PHP 5.5? When the majority of code written in a language is shit, it means the language itself is flawed, and good coders will gravitate towards a better language.

    If it's all just the fault of bad programmers, no one would ever bother fixing languages.

    For example: Java was greatly improved by adding an Enum type. Why? The idioms actual programmers used were half-baked, and the Enum type meant that you didn't have to carefully study the perfect enumerated type class just to do something that should have been simple. That caused programmers to write better code.

    But there are many things about PHP that are just fundamentally broken, like the awful type system, the awful object system, their love of global state and so forth. But there's a group-think among web developers that takes pride in a kludgey mess, and people who don't want to code that way don't use PHP. So the language and the larger community are responsible for the fact that it still sucks. What's sad is that all this web stuff will before long become fossilized like all the horrible awk and sed stuff.

  • facilisis (unregistered) in reply to Jim
    Jim:
    RichP:
    Um no, you use i, j, k and sometimes m as generic counters.

    (cue religious war akin to camelCase versus name_with_underscore)

    in CS101 they taught me to use meaningful names. I have: counter, loopCounter, iter, count and a plethora of others... Of course, to avoid a massive increase in typing, I still use i and then find-replace all i's with count.

    on a totally unrelated note, I found some serious issues in a program I inherited the other day. I don't even know how it compiled for my predecessor:

    publcountc countnt macountn(vocountd)
    {
      for(count=0; count<1000; count++)
      {
        countf(count%5 == 0)
        {
          System.out.prcountntln(count + "counts Dcountvcountscountble by fcountve");
        }
      }
    }
    

    I don't see why some pissants mind single-char variables for controlling short loops. They are insignificant in terms of the purpose of the loop - why bloat the code with a mile-long variable, just so that you can avoid seeing "n" or "i" or whatever?

    Now, I can understand wanting something better than a bunch of different single-char loop-counters in nested loops, but otherwise - in a single-level loop - if you replace my i's with your dumb counter's, for no other apparent reason, expect them to be replaced back (for no other apparent reason).

  • Veldan (unregistered) in reply to Meep
    Meep:
    Spewin Coffee:
    TRWTF is your incredibly false assumption that PHP is a bad language and all programmers who write in PHP are writing bad code.

    ...

    But there are many things about PHP that are just fundamentally broken, like the awful type system, the awful object system, their love of global state and so forth. But there's a group-think among web developers that takes pride in a kludgey mess, and people who don't want to code that way don't use PHP. So the language and the larger community are responsible for the fact that it still sucks. What's sad is that all this web stuff will before long become fossilized like all the horrible awk and sed stuff.

    http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

    This is pretty much the handbook behind why PHP is fundamentally broken. I am usually the first to jump to the defense of languages and am very willing to blame developers. However, with PHP it just isn't that simple.

    You can develop well in PHP but it is a much harder task than basically every other language. This makes it a bad language. Your tools should assist you, not hinder you.

  • kbar (unregistered) in reply to PiisAWheeL

    If you grew up on Fortran everyone knows that I thru N are integers, everything else is a real.

  • VB6? (unregistered)

    VB6 is an object oriented language?

  • GOML (unregistered) in reply to the beholder

    Or he was one of those who picked it up during the Y2K bug and just never quit like he should have.

    Captcha: damnum

    Damnum! Damnum all to hell!

  • Jimbo (unregistered) in reply to Meep
    Meep:
    Spewin Coffee:
    TRWTF is your incredibly false assumption that PHP is a bad language and all programmers who write in PHP are writing bad code.

    Except that the reason certain features were changed in PHP was that they were security holes.

    Everyone who was writing to the spec was writing bad code. When they disallowed those constructs, they forced everyone to write better code.

    So are you going to argue that PHP 4 is just as good as PHP 5.5? When the majority of code written in a language is shit, it means the language itself is flawed, and good coders will gravitate towards a better language.

    If it's all just the fault of bad programmers, no one would ever bother fixing languages.

    For example: Java was greatly improved by adding an Enum type. Why? The idioms actual programmers used were half-baked, and the Enum type meant that you didn't have to carefully study the perfect enumerated type class just to do something that should have been simple. That caused programmers to write better code.

    But there are many things about PHP that are just fundamentally broken, like the awful type system, the awful object system, their love of global state and so forth. But there's a group-think among web developers that takes pride in a kludgey mess, and people who don't want to code that way don't use PHP. So the language and the larger community are responsible for the fact that it still sucks. What's sad is that all this web stuff will before long become fossilized like all the horrible awk and sed stuff.

    NEWS FLASH: Programmers gravitate toward the languages that there are plenty of jobs advertised for. Hobby programmers (or people running their own shops) might have the luxury of choosing their favourite languages, but most of us plebs have to suffer whatever is convenient for the organisation we work for - which often means something that was chosen 10 years ago by a mnagemnt type who had a vague idea that his underlings did nothing but played solitaire all day and the magick happened because he held meetings...

    As the web developed to the point where CGI (Common Gateway interface, not any of the other CGIs) became cumbersome (C programmers using perl, anyone?) the like of PHP (and to a degree JavaScript) became real common. As a lot of traditional programmers were a little anti web development (a web page/site is something any idiot graphic designer can do, right?) a lot of roles in PHP were available, and not a lot of talent was really going for it (there were far more important things to do in the very trendy Java and C# became pretty popular for app development too) so a lot of "google'n'learn" types picked up the most basic ideas of PHP and made a career out of it....

    This still doesn't make PHP itself crap. Nor does it make any of the other languages better...

    I actually think modern languages over-simplify a lot of concepts. While this helps the experienced developer finish tasks more quickly, it often encourages inexperienced developers to right code that is memory (and often time) inefficient. In the old days (you know like before the 80s and 90s ;) ) the programmers would create their own little tools to auto-generate bits of code or simplify little tasks. That is, the individual would have an overhead of crafting their own tools to increase their efficiency. THis obviously would mean that projects take a little longer, because the effort to design these tools is absorbed somewhere, but it also generally meant a better result, because the programmer would have a better understanding of how any auto-generation occured and (more importanbtly) would have a far better understanding of how system resources work and are managed.

    I often get on a hobby horse about inefficient code, and the usual response is "Who cares? We have shirtloads of resources these days". I find this attitude a bit scary - while our resources often can absorb a lot of inefficiency it's no excuse to produce crap. The system you desing for 10 users today might have 100 users tomorrow, and 1000 users next week. The only time you are allowed to write stuff inefficiently is when you are making an app for yourself that will only ever run on your desktop - and even then, why limit the number of programs you can have open at any given time?

  • jumentum (unregistered) in reply to facilisis
    facilisis:
    Jim:
    RichP:
    Um no, you use i, j, k and sometimes m as generic counters.

    (cue religious war akin to camelCase versus name_with_underscore)

    in CS101 they taught me to use meaningful names. I have: counter, loopCounter, iter, count and a plethora of others... Of course, to avoid a massive increase in typing, I still use i and then find-replace all i's with count.

    on a totally unrelated note, I found some serious issues in a program I inherited the other day. I don't even know how it compiled for my predecessor:

    publcountc countnt macountn(vocountd)
    {
      for(count=0; count<1000; count++)
      {
        countf(count%5 == 0)
        {
          System.out.prcountntln(count + "counts Dcountvcountscountble by fcountve");
        }
      }
    }
    

    I don't see why some pissants mind single-char variables for controlling short loops. They are insignificant in terms of the purpose of the loop - why bloat the code with a mile-long variable, just so that you can avoid seeing "n" or "i" or whatever?

    Now, I can understand wanting something better than a bunch of different single-char loop-counters in nested loops, but otherwise - in a single-level loop - if you replace my i's with your dumb counter's, for no other apparent reason, expect them to be replaced back (for no other apparent reason).

    I thinks ye been trolled....

  • Frogger (unregistered) in reply to Jimbo
    Jimbo:
    Meep:
    Spewin Coffee:
    TRWTF is your incredibly false assumption that PHP is a bad language and all programmers who write in PHP are writing bad code.

    Except that the reason certain features were changed in PHP was that they were security holes.

    Everyone who was writing to the spec was writing bad code. When they disallowed those constructs, they forced everyone to write better code.

    So are you going to argue that PHP 4 is just as good as PHP 5.5? When the majority of code written in a language is shit, it means the language itself is flawed, and good coders will gravitate towards a better language.

    If it's all just the fault of bad programmers, no one would ever bother fixing languages.

    For example: Java was greatly improved by adding an Enum type. Why? The idioms actual programmers used were half-baked, and the Enum type meant that you didn't have to carefully study the perfect enumerated type class just to do something that should have been simple. That caused programmers to write better code.

    But there are many things about PHP that are just fundamentally broken, like the awful type system, the awful object system, their love of global state and so forth. But there's a group-think among web developers that takes pride in a kludgey mess, and people who don't want to code that way don't use PHP. So the language and the larger community are responsible for the fact that it still sucks. What's sad is that all this web stuff will before long become fossilized like all the horrible awk and sed stuff.

    NEWS FLASH: Programmers gravitate toward the languages that there are plenty of jobs advertised for. Hobby programmers (or people running their own shops) might have the luxury of choosing their favourite languages, but most of us plebs have to suffer whatever is convenient for the organisation we work for - which often means something that was chosen 10 years ago by a mnagemnt type who had a vague idea that his underlings did nothing but played solitaire all day and the magick happened because he held meetings...

    As the web developed to the point where CGI (Common Gateway interface, not any of the other CGIs) became cumbersome (C programmers using perl, anyone?) the like of PHP (and to a degree JavaScript) became real common. As a lot of traditional programmers were a little anti web development (a web page/site is something any idiot graphic designer can do, right?) a lot of roles in PHP were available, and not a lot of talent was really going for it (there were far more important things to do in the very trendy Java and C# became pretty popular for app development too) so a lot of "google'n'learn" types picked up the most basic ideas of PHP and made a career out of it....

    This still doesn't make PHP itself crap. Nor does it make any of the other languages better...

    I actually think modern languages over-simplify a lot of concepts. While this helps the experienced developer finish tasks more quickly, it often encourages inexperienced developers to right code that is memory (and often time) inefficient. In the old days (you know like before the 80s and 90s ;) ) the programmers would create their own little tools to auto-generate bits of code or simplify little tasks. That is, the individual would have an overhead of crafting their own tools to increase their efficiency. THis obviously would mean that projects take a little longer, because the effort to design these tools is absorbed somewhere, but it also generally meant a better result, because the programmer would have a better understanding of how any auto-generation occured and (more importanbtly) would have a far better understanding of how system resources work and are managed.

    I often get on a hobby horse about inefficient code, and the usual response is "Who cares? We have shirtloads of resources these days". I find this attitude a bit scary - while our resources often can absorb a lot of inefficiency it's no excuse to produce crap. The system you desing for 10 users today might have 100 users tomorrow, and 1000 users next week. The only time you are allowed to write stuff inefficiently is when you are making an app for yourself that will only ever run on your desktop - and even then, why limit the number of programs you can have open at any given time?

    Uhm....no

  • (cs) in reply to VB6?
    VB6?:
    VB6 is an object oriented language?
    no ... it emulates some object oriented practices. For one thing, vb6 does not support inherritence... wich limits the capacity for reusable code. The data types are generally adaptive and interchangable, though you can enforce some degree of strong typing. For all that however, it was damned useful in the classic ASP days.
  • Coder Hero (unregistered) in reply to Zylon
    Zylon:
    Unisol:
    Goddamn it, Remy, I come here to see unicorns and now you're dissapointing me.
    Then go visit www.comeheretoseeunicorns.com.

    I was really hoping that was a real domain.

  • (cs) in reply to soei
    soei:
    Oh, I get it....nn, nnn and nnnn are never used? Or is it that they break the convention used for other variables, and should have been n1, n2, n3, n4 ?
    I don't care what language you are using... if the names of your variables are not either 1: meaningful, or 2: obvious based on direct usage, they are simply wrong. Also... yes, it is a bad practice to declare variables that you are not using. In most languages, memory is reserved for these variables... but more to the point, it is misleading.

    One aspect of coding that should always be observed is that other coders should generally have as easy of a time maintaining your code as possible. The less time we spend trying to figure out whether a variable named nnnn is used, and if so then where... the more time we can spend on doing something useful with the software we are charged to maintain.

  • hewey (unregistered)

    Is it just me, or are today's trolls more successful than usual?

  • Cheong (unregistered)

    Every programming language has it's own set of idomatic expressions.

    Just don't bring them into another obviously different programming languages.

  • foo2 (unregistered) in reply to Cbuttius
    Cbuttius:
    Does it work? Does it do what it is supposed to do?

    I am not sure what it means to subtract 1 from a string. I am surprised that compiles, even in VB.

    VB happily 'fixes' the types for you, and as expected is not a good idea. It will usually compile, and often fail when run. Consider:

    Dim A As String A = 5 A = A - 1

    VB convert the 5 to a string, and then converts A to an integer before doing the decrement.

    Decent programmers force the type changes:

    Dim A As String A = Str(5) A = Str(Val(A) - 1)

    (In this simple case both bits of code with run identically.)

    Programmers with a clue make A an integer in the first place.

    Then you get stuff like this:

    A = "1" + "1"

    The result, of course, is 11. However:

    A = "1" + 1

    ...is 2, either a string or integer depending on how A was declared. As a bonus the string has a space in from of it (a placeholder for the - sign), ie " 11", not "11". Most people use Format() instead of Str() to avoid that.

    MS deprecated using + for string concatenation, replacing it with & instead to prevent this stuff.

    As for the WTF, VB has a bunch of date calculation functions, again showing the real WTF is people, not the language.

  • (cs) in reply to Spewin Coffee
    Spewin Coffee:
    I will agree with anyone that says that PHP makes it easy to write bad code because you can do the same thing about 25 different ways of which only two of those ways is correct.

    It's an "enough rope to hang themselves with" language. VB and C++ fall into this category as well. While C++ gives Rube-Goldberg-like powers to the over engineering veteran, VB lets the amateur get their feet wet enough that they're soon neck deep, while PHP simply drowns the child given long enough.

    One might attach the "easy to pick up, difficult to master" adage to PHP. Which is great for games, but not for writing manageable, secure websites.

  • (cs) in reply to foo2
    foo2:
    VB happily 'fixes' the types for you, and as expected is not a good idea. It will usually compile, and often fail when run.

    Isn't there a strict mode you can set that requires variables be explicitly typed?

    EDIT: Ah yes, Option Explicit is what it was called. It's been a long long while.

  • (cs) in reply to Some Jerk
    Some Jerk:
    I don't care what language you are using... if the names of your variables are not either 1: meaningful, or 2: obvious based on direct usage, they are simply wrong. Also... yes, it is a bad practice to declare variables that you are not using. In most languages, memory is reserved for these variables... but more to the point, it is misleading.

    Agreed! It would be like a book having a table of contents that referred to chapters that didn't actually exist. It doesn't "break" the book, but it's certainly confusing to discover the mismatch. Or perhaps a more practical example would be finding extra parts after assembling your Ikea furniture, leaving you to wonder if they were necessary or not.

  • (cs) in reply to Jimbo
    Jimbo:
    I often get on a hobby horse about inefficient code, and the usual response is "Who cares? We have shirtloads of resources these days". I find this attitude a bit scary - while our resources often can absorb a lot of inefficiency it's no excuse to produce crap. The system you desing for 10 users today might have 100 users tomorrow, and 1000 users next week. The only time you are allowed to write stuff inefficiently is when you are making an app for yourself that will only ever run on your desktop - and even then, why limit the number of programs you can have open at any given time?

    Remember the "triangle of requirements" (as I'm titling it just now). On each corner is marked "fast", "cheap" and "good" respectively. Now you have to pick a side. If you want it fast and cheap, it won't be good; If you want it fast and good, it won't be cheap, etc.

    Optimization is good, but only when it's valuable. For example, a script that's run once a month and takes 1 second to complete does not need a developer spending months, days, or even hours optimizing it, since the value on the return is negligible. When someone disregards an optimization pass on their software, it's usually because it isn't worth it.

    Optimization should be reactive. If a website only gets 5 visitors a day, it isn't valuable enough to warrant the optimization. However, if traffic increases to 50,000 visitors a day then the value of optimization increases and becomes worth pursuing. Software is never "done" and it's never perfect, so trying to pre-optimize often just leads to a lost of wasted time...far more than the optimizations would have saved.

  • (cs) in reply to Soviut

    This is nothing, and as other people have pointed out it doesn't look very much like COBOL.

    Btw. it's spelled C O B O L (COmmon Business Oriented Language), not to be confused with COMAL (COMmon Algorithmic Language), which is a BASIC variant.

    I once had to clean up code after an old COBOL coder, and it was a complete and utter mess. At the time I was lead developer/team leader in a small shop, and one of my colleagues was asked to implement something in Delphi (this was way back with Delphi 2, as far as I remember). The task involved reading a few input files, compute something, and then produce some output files.

    So how did this genius solve this not too complicated problem? By reading and writing all kinds of temporary files with strange filenames and short unintelligble record names. There was no system in it at all, and I'm not even sure he had read any of the requirements. It looked like he expected to be able to reinvent JCL and COBOL in Delphi and mix it all together in something best described as spaghetti code.

    We didn't understand why it didn't work as expected, and it was only when that guy left the company, we discovered this mess. I had to rewrite most of the code from scratch (and I believe my successor eventually moved the whole codebase to another platform).

    PS: COBOL is actually not that bad. It's paid my salary for several years, and I occasionally still work with COBOL or something very similar.

  • Zero_Cool (unregistered) in reply to PiisAWheeL

    Really weird, I used to use exactly the same "naming convention" when I started programming. When I was 6 years old.

    This is the first time I see the exact same names. It's kind of weird. and sad.

  • minime (unregistered)

    please fix this goddamn "cant find brush for java" bug on the frontpage, it is fucking annoying.

Leave a comment on “Globally Fiscal Year”

Log In or post as a guest

Replying to comment #:

« Return to Article