好的命名能使代码逻辑一目了然、心情舒畅。日常在命名变量上花费了大量精力。本文记录常用的命名单词,以备查阅:
名词
- count (用于表示集合中元素的个数)
- size
- length (文件的长度等)
- capacity
- info
- element, item
- position
- helper
- utils
- duration
辅助词
- previous, next (空间上)
- last, next (时间上)
- first, last,current
- before, after
- item, element,
- old, new (oldChar, newChar)
状态
- IsBusy,
- IsEmpty,
- HasValue,
- CanRead, CanWrite
- Exists,
- Invalid
- Contains
- Available
- buffer
词根
- Uni- (UniCode)
- En- (Enqueue)
- De- (Dequeue)
- Dis-
- -wise (--层面, memberwise, bitwise)
- free- (免费,不限)freeSpeed
配对动作
- Get,Set,
- Read,Write,
- Send, Receive,
- Add, Delete,
- Start,Stop,Cancel,
- Begin,End,带begin和end的多为异步操作。
动作
- Create 创建,
- Delete 删除,
- Load 加载
- Clear
- GetType 获取类型。
- DoWork,
- ProgressChanged,
- RunWorkerCompleted, 运行、执行用Run
- ReportProgress,
- RunWorkerAsync,开始执行后台操作。
- CancellationPending,
- CancelAsync,取消挂起的后台操作。
- WorkerSupportsCancellation,
- InitializeBackgroundWorker, 初始化
- StartAsyncButton,
- GetLastAccessTime,
- Operation
- earlier than, the same time, later than, less than,
- validity check,
应用
- display data
- shape data (sort, filter, group,summary,calculation, cell merging ,etc)
- edit data
- traditional
- original
- mono 单声道
- recent time
- engine, model, handle