How to name variables

前端 未结 24 1325
抹茶落季
抹茶落季 2020-12-01 00:37
  • What rules do you use to name your variables?
  • Where are single letter vars allowed?
  • How much info do you put in the name?
  • How about for exam
24条回答
  •  悲哀的现实
    2020-12-01 01:24

    What rules do you use to name your variables?

    • I need to be able to understand it in a year's time. Should also conform with preexisting style.

    Where are single letter vars allows?

    • ultra-obvious things. E.g. char c; c = getc(); Loop indicies(i,j,k).

    How much info do you put in the name?

    • Plenty and lots.

    how about for example code?

    • Same as above.

    what are your preferred meaningless variable names? (after foo & bar)

    • I don't like having meaningless variable names. If a variable doesn't mean anything, why is it in my code?

    why are they spelled "foo" and "bar" rather than FUBAR

    • Tradition.

提交回复
热议问题