When is a function name too long?

后端 未结 27 1644
伪装坚强ぢ
伪装坚强ぢ 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:46

    When it contains information which is obvious from context (e.g., incrementInteger(int x), long longID), useless (e.g., ObsoleteIncrementer, RobertsCarFactory), incomprehensible (e.g., TheFunctionThatRobertWorkedOnLastWeekButDidntFinish), numeric (e.g., id1, id2, id3) or otherwise doesn't help understanding or contains a code smell. Note that even though some part of the names above should be pruned, you might need to pad them with useful information to keep them unique and make them understandable, as in person_id for id1, employer_id for id2 etc..

提交回复
热议问题