问题描述
我正在阅读清洁代码 http://www .amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
作者提到您应该在类名中避免使用诸如Manager,Processor,Data或Info之类的词.我到处都用过这些.有什么更好的名字?我有一个负责启动和停止连接的类.所以我将其命名为ConnectionManager.
The author mentions that you should avoid words like Manager, Processor, Data or Info in the name of the class. I have used these everywhere. What are some better names? I have a class that is responsible for starting and stopping connections. So I named it ConnectionManager.
推荐答案
等待!
这本书的重点是,类名中的Manager意味着该类可以做很多事情.罗伯特·马丁(Robert C. Martin)在本节中提到了单一责任原则"!
The point of the book is, that Manager in the classname means the class does more than one thing. Robert C. Martin refers in this section to the Single Responsibility Principle!
这与名称无关,而与通常这样命名的类有关.更改名称不会减轻班级的责任!
This is not about the name, its about the classes which are usually named like this. Changing the name won't reduce the responsibilities of a class!
这篇关于有什么比经理,处理器等更好的名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!