.net 您发现自己经常在课程中添加/添加哪些名称?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1194403/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 13:05:00  来源:igfitidea点击:

What names do you find yourself prepending/appending to classes regularly?

.netnaming-conventions

提问by Chris S

Which nouns do you find yourself putting regularly at the end of your classes?

您发现自己经常在课程结束时使用哪些名词?

For example, I have a habit of sticking Infoonto classes that pass information around but don't do a great deal:

例如,我习惯于坚持Info传递信息但没有做太多事情的类:

  • ImportInfo
  • SiteInfo
  • ImportInfo
  • SiteInfo

Or for Coordinating classes:

或者对于协调类:

  • UserManager
  • SecurityManager
  • UserManager
  • SecurityManager

I end up using Builderquite often for string related classes, even if it barely does any building:

我最终Builder经常使用与字符串相关的类,即使它几乎没有任何构建:

  • TemplateBuilder
  • HtmlBuilder
  • TemplateBuilder
  • HtmlBuilder

And of course the timeless Helper/Utility class:

当然还有永恒的 Helper/Utility 类:

  • PhraseHelper
  • NumberUtility
  • FileHelper
  • PhraseHelper
  • NumberUtility
  • FileHelper

Have you got any good, by which I mean concise and descriptive, nouns or words you regularly use to denote the class' main role?

你有什么好的,我的意思是简洁和描述性的,你经常用来表示班级主要角色的名词或词吗?

This question is aimed at the .NET world, but can extend to Java, C++, Python and so on.

这个问题是针对 .NET 世界的,但可以扩展到 Java、C++、Python 等。

回答by Markus Meyer

You can take a look at source-code-wordle.de, I have analyzed there the most frequently used suffixes of class names of the .NET framework and some other libraries.

您可以查看source-code-wordle.de,我在那里分析了 .NET 框架和其他一些库的类名最常用的后缀。

The top 20 are:

前20名是:

  • attribute
  • type
  • helper
  • collection
  • converter
  • handler
  • info
  • provider
  • exception
  • service
  • element
  • manager
  • node
  • option
  • factory
  • context
  • item
  • designer
  • base
  • editor
  • 属性
  • 类型
  • 帮手
  • 收藏
  • 转换器
  • 处理程序
  • 信息
  • 提供者
  • 例外
  • 服务
  • 元素
  • 经理
  • 节点
  • 选项
  • 工厂
  • 语境
  • 物品
  • 设计师
  • 根据
  • 编辑

回答by Arnis Lapsa

I append pattern name at the end if i follow one (i.e. FooRepository).
Trying to avoid -Helper, -Manager, -Utils.

如果我遵循一个模式名称(即 FooRepository),我会在末尾附加模式名称。
试图避免 -Helper、-Manager、-Utils。

回答by NotMe

I use Provider and Helper a lot.

我经常使用 Provider 和 Helper。

回答by JaredPar

Util

实用程序

  • EnumUtil
  • ParseUtil
  • StringUtil
  • etc ...
  • 枚举实用程序
  • 解析实用程序
  • 字符串实用程序
  • 等等 ...

回答by David Anderson

Base, Reader, Writer, Manager, File.. some others.

Base、Reader、Writer、Manager、File.. 其他一些。

回答by Matthew Jones

If my class is specifically doing calculations, I will prepend Calc

如果我的班级专门做计算,我会在 Calc 前面加上

Examples:

例子:

  • TaxCalc
  • TipCalc
  • DateCalc
  • 税务计算器
  • 小费计算器
  • 日期计算器

回答by Chet

I find myself sometimes appending the name of the parent class the one I'm writing I want to inherit. Sometimes it sounds weird especially with an Animal example (DogAnimal, FishAnimal, ...) but it makes finding subtypes easier in a list of classes.

我发现自己有时会附加父类的名称,即我正在编写的我想继承的类。有时听起来很奇怪,尤其是对于 Animal 示例(DogAnimal、FishAnimal,...),但它使在类列表中更容易找到子类型。

回答by Matthieu

I am often using :

我经常使用:

  • Protocol (Specific protocol implementation)
  • Manager (Class managing the process)
  • Emulator (Emulate something...)
  • 协议(特定协议实现)
  • 经理(管理流程的班级)
  • 模拟器(模拟某些东西...)

回答by t3rse

On occasion I use

有时我使用

Target

目标

As in

  • UploadTarget
  • ProcessingTarget
  • 上传目标
  • 处理目标

I don't think I had before Silverlight / WPF but I now also use

我不认为我在 Silverlight/WPF 之前有过,但我现在也使用

Converter

转换器

As in:

如:

  • CurrentTimeDisplayConverter
  • TimeDeltaConverter
  • 当前时间显示转换器
  • 时间增量转换器

回答by Charlie

Testsfor unit test classes

Tests对于单元测试类