有什么比经理,处理器等更好的名字? [英] What is a better name than Manager, Processor etc?

查看:67
本文介绍了有什么比经理,处理器等更好的名字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读清洁代码 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!

这篇关于有什么比经理,处理器等更好的名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆