Reading code and discussions pertaining to code, I often see the words "state" and "status" used interchangeably, but the following tendencies seem to exist:

When a variable holds a value intended to indicate that something is in a certain state, the name of that variable more often than not contains the word "state", or an abbreviation thereof.

However, when the return value of a function serves to indicate some such state, we tend to call that value a "status code"; and when that value is stored in a variable, this variable is commonly named "status" or something similar.

In isolation that's all fine I guess, but when the aforementioned variables are actually one and the same, a choice needs to be made involving the perverted intricacies of English language (or human language in general).

What is the prevailing coding-standard or convention when it comes to disambiguating between the two? Or should one of those two always be avoided?

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.
If this question can be reworded to fit the rules in the help center, please edit the question.

2

Hence this attempt at crowdsourcing. This is very much not the place for opinion polling, though.
–
Martijn PietersNov 24 '13 at 2:20

@MartijnPieters Technically, you're probably right about that. Nevertheless, I'm not convinced it's a bad question for this site. What is the best place for this question according to you?
–
WillNov 24 '13 at 2:32

Not on any Stack Exchange site; a forum perhaps?
–
Martijn PietersNov 24 '13 at 2:35

3 Answers
3

From what I've seen "state" is often used for things that can change and the programmer has at least some modicum of control over how/when it changes (even if indirectly). It also almost always is used to refer to positive states. "You have placed the connection into a disconnected state."

"Status" tends to be the opposite. It tends to be used for things that happen without the programmer's input - and often that the programmer cannot change. It also tends to be used for for negative statuses. "The status of your connection is (checking...) disconnected."

I like this question. The following is from my head but I think it fits quite well.

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).

I also like this definition:

status is a final (resulting) state.

It is quite clear when applied to programming. Much less clear when you apply it to natural language. Let's take the examples from the english thread and see if it holds with the most upvoted answer.

"What is the current status of this project?" The answer should be "In testing."

Well, this might seem to contradict my definitions at a first look but we must realize the context. Probably some supervisor is asking his team about the project and how far they have reached. The point is that the supervisor is interested in the outcome up to now. The fact that there will be something after is just put away because it is not the point of the question.

"What is the current state of this project?" The answer should be "On hold for financial analysis."

So I think that this very nicely demonstrates an essence of a state. "On hold for financial analysis." clearly focuses on the fact that the current situation is a part of some encompassing process and even suggests the next state.

"State" makes me think of "state machine", and I typically use it to refer to something internal / technical, like, "open", "parsing header", "negotiating formats", "reading text", "reading video", etc. Something a fellow programmer might care about, but not intended (much) for the end user. Maybe if they ask for more details on an error, but not the first thing they see.

"Status" is less techie and more for an end user, e.g. "reading", "error 404", "success 200".