Are hard-coded STRINGS ever acceptable?

后端 未结 9 1066
臣服心动
臣服心动 2021-01-07 04:21

Similar to Is hard-coding literals ever acceptable?, but I\'m specifically thinking of \"magic strings\" here.

On a large project, we have a table of configuration o

9条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 04:53

    If I use a string once in the code, I don't generally worry about making it a constant somewhere.

    If I use a string twice in the code, I'll consider making it a constant.

    If I use a string three times in the code, I'll almost certainly make it a constant.

提交回复
热议问题