API 方法族命名规则

API methods family naming rules

你会调用一系列 API 方法吗 (程序员更容易找到)

(流利的英文更容易阅读)

?

在哪里可以找到有关此主题的优缺点讨论?

谢谢。

很难找到专门针对您的确切主题的内容,但我找到了这个,它仅解决了您的问题:

  • ThingAbstract: "Abstract" suffix. Unnatural language. Appears next to ThingInterface in file listings.
  • AbstractThing: "Abstract" prefix. Natural language. Far off from ThingInterface in file listings.

Source: https://www.drupal.org/project/coding_standards/issues/1567920

除了提到自然性,它还谈到了列表顺序,这可以帮助理解项目的结构(alltough 子文件夹应该弥补这一点)。

这是关于 Whosebug 的另一个答案,其中指出

As for the names of classes, it would be typical to prefix the class name with the specialization [..]

Source: The C# namespace and class/sub-class naming conventions when the top namespace contains the base class and inner namespaces contain sub-classes


我认为,这主要是基于意见,我个人更喜欢第二种方式 (RoundedRectangle),因为它阅读起来更自然,因此更容易理解。我还认为(正如我经常在网上阅读的那样),我们应该尽量使 class 名称尽可能重要。

Microsoft 推荐(并在 .NET 框架中使用)形式:RoundedRectangle。

MS 提供了非常有用的 Naming Guidlines 文档。您可以在 类 的名称、结构和接口 章节中找到以下内容:

CONSIDER ending the name of derived classes with the name of the base class.