Am I immoral for using a variable name that differs from its type only by case?

前端 未结 8 994
醉梦人生
醉梦人生 2021-02-11 11:43

For instance, take this piece of code:

var person = new Person();

or for you Pythonistas:

person = Person()

I

相关标签:
8条回答
  • 2021-02-11 12:33

    I use this pattern a lot in method signatures. If I'm unable to provide an alternate descriptive name then IMHO, there is nothing wrong with this.

    What is wrong would be if you have two types Person and person then that is very very wrong.

    0 讨论(0)
  • 2021-02-11 12:33

    I suppose I'll get downvoted for saying so, but ...

    Having just come through a century witnessing epic murder and greed, we programmers are truly blessed if the most immoral thing we can do is name a variable.

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