Very long class names

后端 未结 7 1576
一个人的身影
一个人的身影 2021-02-18 13:41

I try to name a class (also members, properties and so forth) as exact as I can. But sometimes I’m not sure if this is so clever if the class name becomes huge (50 chars and mor

7条回答
  •  逝去的感伤
    2021-02-18 13:56

    Have you an approximate upper limit and then make abbreviations or is it worth the pain to handle such long names?

    Neither. No abbreviations except extremely well-knonw ones like URL or HTTP. And perhaps for local variables with very small scope. Otherwise, think harder about how to get names that are both descriptive and not very long (I'd say anything over 30 characters is too long).

    Usually, long names contain redundant or irrelevant information that can be left out. For example, don't put information in there that is already provided from context (i.e. information in member names that is already present in the class name). And avoid unspecific filler words like "data", "information", "handler", "manager", "helper", "compute", "processor" - they describe pretty much all code and so contain no real information (and some of them reflect procedural concepts and are almost a code smell for that alone).

提交回复
热议问题