Very long class names

后端 未结 7 1580
一个人的身影
一个人的身影 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:58

    (I use Java/C++, and have used other OO languages, but not C#, what I say here pretty much applies to all the languages I have used)

    I use descriptive class names. I don't think I have made it to 50 characters however :-) Generally long class names are not public, and are usually hidden behind an interface and a factory. The interface has a much shorter name than the classes.

    One thing you might do is, assuming you have a number of long-named classes that are closely related, put them into a package. One way to spot this is if the classes all have the same prefix word(s). If there are a number of classes that all start with the same name then, perhaps, the name should be a package instead.

提交回复
热议问题