在写面向对象程序代码时有时想不起来应该用什么单词给类/方法/变量命名,下面把一些常用单词列出来,供以后写程序时参考:
源/基/头
Root
Source
Home
Base
Head
获取器或查询器
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
用户角色相关
Signer
Owner
User
Member
Operator
Authenticator
代理类
Proxy
Broker
Delegate
Gateway
监控,跟踪或探查器
Detector
Profiler
Monitor
Tracker
Introspector
多线程相关
Synchronizer
Blocker
Holder
Worker
Runner
辅助类或工具类
Helper
Support
Supporter
Util
Utility
Kit
Tool
Toolkit
创建或生成器
Maker
Creator
Generator
Constructor
Builder
Supplier
Provider
Factory
选择器或决策器
Chooser
Selector
Mediator
Arbitrator
Decider
Allocator
Scheduler
处理器/执行器
Resolver
Processor
Handler
Executor
Performer
Runner
管理或控制器
Ruler
Controller
Manager
Ordinator
Leader
Boss
Master
交易
business
deal
trade
transaction
用户/客户
user
customer
player
转换器
Formatter
Marshaller / Unmarshaller
Encoder / Decoder
Transformer
Converter
Packer / Extractor
单一功能
Descriptor
Counter
Viewer
Locator
Accumulator
Recognizer
Scroller
Printer
Compiler
Cleaner
Reader / Writer
Buffer
Collector
Connector
Scanner
Linker
Mapper
Streamer
Enhancer
Renderer
Painter
Weaver
adapter
Classifier
一般的/通用的/正常的
general
normal
simple
universal
regular
basic
generic
处理
handle
process
deal
operate
dodispose
tackle
cope
阶段
stage
phase
服务编排/组合
composition 组合 (包含:orchestration和choreography)
orchestration 编排/组合 ≈ composition
choreography 编舞/协同 ≈ collaboration
工作/任务
work
job
task
说明/描述/摘要
comment
note
description
summary