Parameter naming: filename or fileName?

前端 未结 9 2019
情歌与酒
情歌与酒 2020-12-29 19:26

I try to be grammatically correct in my naming*. I\'ve always used filename instead of fileName. The java convention also seems to use this, but

相关标签:
9条回答
  • 2020-12-29 20:01

    As far as I am concerned,

    thisIsMuchMoreReadable than readingthis.

    0 讨论(0)
  • 2020-12-29 20:02

    'filename' assumes that this word describes a singular object like 'cow' or 'chair'
    'fileName' assumes that this is a complex object, that there is an object called file and that this object describes the name of that file.

    Two philosophical approaches, take your pick.

    0 讨论(0)
  • 2020-12-29 20:04

    I think the answers here are spanning two issues.

    • 'FileName' vs 'Filename' (should 'name' be a separate word)

      and

    • 'fileName' vs 'FileName' (should first character be lower case).

    In most cases, I prefer to treat this word as a single whole word 'filename'. I also prefer starting variables/methods with lower case for easier code completion menu navigation.

    I guess the issue of camel case is here too which I think should be used to distinguish multi-word names.

    0 讨论(0)
提交回复
热议问题