首页 > 代码库 > 给类命名的常用单词

给类命名的常用单词

在写面向对象程序代码时有时想不起来应该用什么单词给类命名,下面把一些常用单词列出来,供以后写程序时参考:


获取器或查询器:

Getter
Finder
Accessor

验证器或比较器:
Checker
Matcher
Validator
Comparator
Sorter

修改器或编辑器:
Modifier
Updater
Adjuster
Editor

发送器或接收器:
Emitter
Sender / Receiver
Broadcaster / Multicaster

访问器或迭代器:
Visitor
Iterator

生命周期相关:
Loader
Parser
Constructor / Maker / Creator / Generator
Initializer
Register
Activator
Starter
Stopper
Destroyer

事件相关:
Listener
Producer / Consumer
Observer / Observable
Timer

封装或容纳:
Adapter
Wrapper
Container
Server

过滤器或拦截器:
Filter
Interceptor

单一功能:
Loader
Parser
Register
Descriptor
Formatter
Marshaller / Unmarshaller
Encoder / Decoder
Counter
Viewer
Locator
Accumulator
Recognizer
Scroller
Printer
Compiler
Cleaner
Reader / Writer
Buffer
Transformer
Collector
Converter
Connector
Packer / Extractor
Scanner
Linker
Mapper
Streamer
Scheduler
Enhancer
Renderer
Painter
Weaver

用户角色相关:
Signer
Owner
User
Member
Operator
Authenticator

代理类:
Proxy
Broker
Delegate
Gateway

监控,跟踪或探查器:
Detector
Profiler
Monitor
Tracker
Introspector  

多线程相关:
Synchronizer
Blocker
Holder
Worker

辅助类或工具类:
Helper
Supporter
Util
Utility
Kit
Tool
Toolkit

创建或生成器:
Maker
Creator
Generator
Constructor
Builder
Supplier
Provider
Factory

选择器或决策器:
Chooser
Selector
Mediator
Arbitrator

处理器:
Resolver
Processor
Handler
Executor

管理或控制器:
Ruler
Controller
Manager
Ordinator
Leader
Master

给类命名的常用单词