Java 命名约定是否允许 `ClassName` 有两个首字母大写?
Does Java naming convension allow `AClassName` with two first capital letters?
我正在为 class 报告系统事件消息选择一个名称。可能的名称:
(1) SystemEventMessage
//SystemEventMessageReportController
太长了
(2) EventMessage
//与太阳发生冲突。plugin2.message.EventMessage
(3) Message
//与多个classes
冲突
(4) EMessage
或 SMessage
// 首选方式
是否允许 class 名称如 EMessage
?这个名字有什么潜在的问题?
这是一种常见的命名方式。 Java Swing 有核心 类 HBox
, VBox
, 等等
即使它被使用(正如 Victor 在他的回答中所写),也不意味着它被 Java code convemtions 推荐:
Class names should be nouns, in mixed case with the first letter of
each internal word capitalized. Try to keep your class names simple
and descriptive. Use whole words-avoid acronyms and abbreviations
(unless the abbreviation is much more widely used than the long form,
such as URL or HTML).
我正在为 class 报告系统事件消息选择一个名称。可能的名称:
(1) SystemEventMessage
//SystemEventMessageReportController
太长了
(2) EventMessage
//与太阳发生冲突。plugin2.message.EventMessage
(3) Message
//与多个classes
冲突
(4) EMessage
或 SMessage
// 首选方式
是否允许 class 名称如 EMessage
?这个名字有什么潜在的问题?
这是一种常见的命名方式。 Java Swing 有核心 类 HBox
, VBox
, 等等
即使它被使用(正如 Victor 在他的回答中所写),也不意味着它被 Java code convemtions 推荐:
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).