命名约定:“状态” 与“状态”相对

发布于 2024-07-27 04:42:57 字数 1433 浏览 11 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

酒废 2024-08-03 04:42:57

IMO:

状态==你好吗? [好/坏]

状态==你在做什么? [休息/工作]

IMO:

status == how are you? [good/bad]

state == what are you doing? [resting/working]

ゃ人海孤独症 2024-08-03 04:42:57

这取决于上下文。

状态通常是指实体的整个状态 - 在特定时间点(通常是当前)的所有值和关系 状态

更多的是一个时间点,例如,流程或工作流程中的某个事物所处的位置 - 是吗?脏(因此需要保存)、是否完整、是否等待输入等

It depends on the context.

State generally refers to the entire state of an entity - all its values and relationships at a particular point in time (usually, current)

Status is more of a time-point, say, where something is at in a process or workflow - is it dirty (therefore requiring saving), is it complete, is it pending input, etc

傲世九天 2024-08-03 04:42:57

通常我会使用状态来表示对象或整个系统的当前状况。 我用状态来代表某些行动的结果。 例如,对象的状态可以是已保存/未保存、有效/无效。 方法的状态(结果)是成功/不成功/错误。 我认为这与状态的定义非常吻合,即“相对于情况的状态或条件” ”,这种情况下的情况是动作/方法的应用。

Typically I will use State to mean the current condition of an object or the system as a whole. I use status to represent the outcome of some action. For example, the state of an object may be saved/unsaved, valid/invalid. The status (outcome) of a method is successful/unsuccessful/error. I think this jibes pretty well with the definition of status as "state or condition with respect to circumstances," the circumstances in this case being the application of an action/method.

半世晨晓 2024-08-03 04:42:57

更喜欢使用状态而不是状态的另一个(完全务实的)原因是复数形式很简单:

  • 状态 -> 状态。 状态
  • 状态-> 相信

我,您迟早会在代码中拥有一个列表或数组或任何状态,并且必须命名该变量。

Another (entirely pragmatic) reason to prefer state over status is that the plural is straightforward:

  • state -> states
  • status -> statuses

And believe me, you will sooner or later have a list or array or whatever of states in your code and will have to name the variable.

痴情换悲伤 2024-08-03 04:42:57

我想很多人用“Status”来代表一个物体的状态,如果没有其他原因,“State”指的是美国的政治分裂。

I think many people use "Status" to represent the state of an object if for no other reason than "State" refers to a political division of the United States.

匿名。 2024-08-03 04:42:57

我认为您可以在等式中添加另一个视角,即“发送者-请求者”。

从发送者的角度来看,我会与任何愿意倾听的人传达我的状态。 从请求者的角度来看,我会询问某人的状态。

上述内容也可以从不确定性的角度解释:

  • 已定义 = 状态
  • 未定义 = 状态

您的状态是什么? 我处于轻松的状态。

我很确定这只是一种解释,可能不适用于您的特定情况。

I think you could add another perspective to the equation, namely 'sender-requester'.

From a senders perspective, I'd communicate my state with anyone willing to listen. While from a requesters perspective, I'd be asking for someone's status.

The above could also be interpreted from an uncertainty point of view:

  • Defined = state
  • Undefined = status

What's your status? I'm in a relaxed state.

I'm pretty sure this is just one interpretation, which may not apply to your particular situation.

尐籹人 2024-08-03 04:42:57

快速字典检查显示,状态是状态的同义词,但对相对于其他人的位置有额外的解释。

因此,我将使用 state 来表示一组没有任何隐式排序或相对于彼此的位置的状态,并使用 status 来表示那些具有隐式排序或相对位置的状态(可能处于非待机状态) -在 ?)。 但这是一个很好的区别。

A quick dictionary check reveals that status is a synonym for state, but has an additional interpretation of a position relative to that of others.

So I would use state for a set of states that don't have any implicit ordering or position relative to one another, and status for those that do (perhaps off-standby-on ?). But it's a fine distinction.

暮凉 2024-08-03 04:42:57

我处理的许多实体(账户、客户)可能有一个州(TX、VA 等)和一个状态(活动、关闭等),

因此该术语可能具有误导性。 我们有一个标准化的数据库命名约定(不是我个人的选择),其中状态名为 ST_CD,状态为 ACCT_STAT_CD

对于 OO 环境中的枚举,这个问题并不那么重要,因为如果你有严格的类型安全,编译器将确保没有人尝试这样做:

theCustomer.State = Customer.Status.Active;

如果你在动态环境中,我会更担心!

如果您正在处理一个状态机或其他状态信息并且该术语占主导地位的领域,那么我认为状态完全没问题。

A lot of the entities I deal with (accounts, customers) may have a State (TX, VA, etc.) and a Status (Active, Closed, etc.)

So the point about the term being misleading is possible. We have a standardized database naming convention (not my personal choice) where a state is named ST_CD and a status would be ACCT_STAT_CD.

With an enum in an OO milieux, this issue is not as important, since if you have strict type safety, the compiler will ensure that no one attempts to do this:

theCustomer.State = Customer.Status.Active;

If you are in a dynamic environment, I would be more worried!

If you are dealing with a domain where state machines or other state information and that terminology is predominant, then I would think State is perfectly fine.

守护在此方 2024-08-03 04:42:57

不久前我们就我当前的项目进行了确切的辩论。 我确实没有偏好,但一致性是一个重要的考虑因素。

在我的夏普 PW-E550(一本很棒的字典,我可能会补充)中,“状态”的第一个(有几个)定义是“某人或某物在特定时间所处的特定条件”。 “地位”的第一个定义是“某人或某物的相对社会、专业或其他地位”。 在这种情况下,甚至“地位”的第二个(也是最后一个)定义也低于“国家”:“特定时间的事务地位,尤其是在政治或商业背景下”。

因此,如果我们希望使用我的词典(它使用新牛津美国词典,2001 年)的人尽可能简单,“state”将是最佳选择。

此外,四人帮的书中描述了一种称为状态模式的设计模式,牢固地在计算词典中确立了该术语。

出于这些原因,我建议“状态”。

PS是你DDM吗? 你还在为“国家”与“地位”而苦恼吗?!!!!!! LMAO!

We had this exact debate on my current project a while back. I really don't have a preference, but consistency is an important consideration.

The first (there are several) definition of "state" in my Sharp PW-E550 (an awesome dictionary, I might add) is "the particular condition that someone or something is in at a specific time." The first definition of "status" is "the relative social, professional, or other standing of someone or something". Even the second (and last) definition of "status" is inferior to "state" in this context: "the position of affairs at a particular time, esp. in political or commercial contexts."

So if we wanted it to be as easy as possible for someone using my dictionary (it uses the New Oxford American Dictionary, 2001), "state" would be the best choice.

Furthermore, there is a design pattern described in the Gang of Four's book called the State Pattern, firmly establishing the term in the computing lexicon.

For these reasons I suggest "state".

P.S. Is that you DDM? Are you still bitter about "state" versus "status" ?!!!!!!! LMAO!

花海 2024-08-03 04:42:57

根本不是同一件事。 停止和开始是状态。 停止和启动是状态。

如果您使它们相同,您如何将车辆描述为已停止但当前正在启动。 或者当前已提交但尚未进入审批流程或正在审批但目前处于等待签名错误状态的申请?

Not the same thing at all. Stopped and started are states. Stopping and starting are status.

If you make them them the same thing how do you describe the vehicle as stopped but is currently starting. Or an application as currently lodged but hasn't yet entered the approval process or is being approved but is currently on hold with an error condition of awaiting signature?

千紇 2024-08-03 04:42:57

嗯,它们的意思确实是一样的。 我认为没有必要宣扬其中一种对另一种的强烈偏好,但我通常会选择“地位”,因为我喜欢听起来拉丁和古典主义的东西。 我的意思是,在我的世界里,模式的复数是模式,所以对我来说,几乎没有其他方法可以实现。

Well, they do mean the same thing. I don't think it's necessary to promulgate a great preference of one over the other, but I would generally go with "status", because I like things that sound Latinate and classicist. I mean, in my world, the plural of schema is schemata, so there's pretty much no other way for it to go, with me.

海之角 2024-08-03 04:42:57

Sophistifunk,我相信您会得到有关“状态”和“地位”的论点。 最重要的是你选择一个,并且只使用一个。 我建议与您的团队讨论这个问题,看看每个人都同意什么。

也就是说,我的建议如下。

假设您使用面向对象的编程语言,对象的“状态”由对象本身表示。 在我看来,SomeObject.state 具有误导性。 我不确定你的例子中的“状态”代表什么,但我的自然直觉是更喜欢这个而不是状态。

Sophistifunk, I'm sure you'll get arguments for both State and Status. The most important thing to do is that you pick one, and use only one. I'd suggest discussing this with your team and see what everyone agrees on.

That said, my suggestion is as follows.

Assuming you are using an object-oriented programming language, an object's "state" is represented by the object itself. SomeObject.state is misleading imo. I'm not sure what "status" represents in your example, but my natural intuition is to prefer this to state.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文