What names do you find yourself prepending/appendi

2019-01-29 19:30发布

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

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

  • ImportInfo
  • SiteInfo

Or for Coordinating classes:

  • UserManager
  • SecurityManager

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

  • TemplateBuilder
  • HtmlBuilder

And of course the timeless Helper/Utility class:

  • 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.

14条回答
叛逆
2楼-- · 2019-01-29 19:44

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.

查看更多
Luminary・发光体
3楼-- · 2019-01-29 19:52

Controller and View.

查看更多
Anthone
4楼-- · 2019-01-29 19:53

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

查看更多
太酷不给撩
5楼-- · 2019-01-29 19:56

Util

  • EnumUtil
  • ParseUtil
  • StringUtil
  • etc ...
查看更多
beautiful°
6楼-- · 2019-01-29 19:58

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.

The top 20 are:

  • attribute
  • type
  • helper
  • collection
  • converter
  • handler
  • info
  • provider
  • exception
  • service
  • element
  • manager
  • node
  • option
  • factory
  • context
  • item
  • designer
  • base
  • editor
查看更多
一夜七次
7楼-- · 2019-01-29 19:58
Factory

Also:

Provider
查看更多
登录 后发表回答