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

前端 未结 8 999
醉梦人生
醉梦人生 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:15

    What is the reasoning of those telling you this is bad? I do this all the time. It is the simplest, expressive way to name a single variable of a type. If you needed two Person objects then you could prefix person with meaningful adjectives like

    fastPerson
    slowPerson
    

    otherwise just

    person
    

    is fine with me.

提交回复
热议问题