状态字段应该使用 "status" 还是 "state"

设计 About 544 words

stackexchange 上的解释

  • status is used to describe an outcome of an operation (e.g. success/fail).
  • state is used to describe a stage in a process (e.g. pending/dispatched).
  • status is a final (resulting) state.

status

用来描述操作的结果,比如:成功/失败。表示一个终结状态。

state

用来描述过程的某个阶段,比如:进行中/已发送;处理完成后“进行中”就变成“已发送”了。

举例

  • 订单状态:order_state
    • 订单创建
    • 待付款
    • 付款确认中
    • 付款成功
    • 退款中
    • 退款成功
  • 操作是否成功:operation_status
    • 成功
    • 失败

参考

“state” or “status”? When should a variable name contain the word “state”, and when should a variable name instead contain the word “status”?

“Status” vs. “state”

Views: 6,023 · Posted: 2020-01-08

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh