When is a function name too long?

后端 未结 27 1545
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 18:45

I try to be rather descriptive with my function names, where possible. This occasionally results in function names in the twenty to thirty character range such as \"GetActionFr

27条回答
  •  情歌与酒
    2021-02-03 18:50

    If the function name is 'too long' then it is likely that the function itself is also too long and has too much responsibility. Many wise programmers say that a function should do one thing and one thing only. A function whose name that has to be long to accurately describe what it does is likely to be a good candidate for refactoring into multiple smaller and simpler private functions that consequently have shorter names.

提交回复
热议问题