17
Hero
8y

When you're naming variables, it is not acceptable for them to be one character, especially when that character bares no relevance to the information it stores.

'f' is not a good variable name for an array of strings now, is it...

Comments
  • 1
    I'll fight a dev over that! lol
  • 5
    Yet somehow I find it totally fine to name a variable "i".

    If($i = 0; $i < 5; $i++)
    {
    print $i;
    }

    (i know what you're getting at tho)
  • 1
    @molgamus I agree, an integer named i in a C style loop is passable.
  • 1
    for (String s : stringArray) Log.print(s);
    How's that not acceptable?
    However I would indeed go nuts if you named it 'f'.
  • 1
    it's like when naming a variable $temp as you only store it temporarily, but then you end up using it again and again. Name it properly in the first place!
  • 0
    I do this more than I should, especially in Python code. Then I watched a talk on Python style guides and maybe I need to relax about strict adherence to PEP8 and if a variable name causes a line to get long but is more easily understood then do that.
  • 0
    I've thought of "i" as "iterator". For nested iterations, there is also "j", the "jitterator". In particular when breaking out of outer loops.
  • 0
    i and j are the exceptions. lol Anything else and it's on!
  • 0
    @mlem

    for ($item in $collection){
    # process current item
    }

    It could also be an acronym for item I guess
Add Comment