TransWikia.com

More **state** and more complex

English Language Learners Asked on October 1, 2021

public Customer FindLuckyCustomer(IEnumerable<Customer> customers)
{
   foreach (Customer customer in customers)
       if (IsLucky(customer))
           return customer;

   return null;
}
public Customer FindLuckyCustomer(IEnumerable<Customer> customers)
{
   Customer result = null;

   foreach (Customer customer in customers)
       if (IsLucky(customer))
       {
           result = customer;
           break;
       }

   return result;
}

[The second] version has more lines of code, more state and more complex flow control. To me it’s more complex than the version with multiple returns. We have removed one complexity, and introduced a different one which turns out to be worse.

https://www.anthonysteele.co.uk/TheSingleReturnLaw.html

What is the reason to use "state" in a singular form, not "states"? Is it a typo or the word is used as an adjective? And in case it is used as an adjective, what exactly the author mean?

One Answer

In this context state is an uncountable noun (not an adjective) meaning "management of state and related concerns." A more colloquial way of saying it would be "more saving and keeping track of data."

(In this case it refers to the use of the result variable.)

As is helpfully pointed out in a comment, this is computer jargon. Most English speakers would not be able to define it correctly or understand it correctly.

Depending on context, and arguably in this context, "state" might not refer to the process of keeping track of data but rather to the data itself. You could say that the result variable is state. An example of the word in this sense may be found in the Wikipedia article Session (computer science). The opening paragraph uses the phrase "state information" instead of "state":

A session is typically stateful, meaning that at least one of the communicating parties needs to hold current state information and save information about the session history in order to be able to communicate, as opposed to stateless communication, where the communication consists of independent requests with responses.

Later, the word state is used as a synonym for state information:

For example, an HTTP exchange between a browser and a remote host may include an HTTP cookie which identifies state, such as a unique session ID, information about the user's preferences or authorization level.

I would also note that if you thought that state was an adjective because of its parallel use with complex, you have been misled either by the noun phrase complex flow control or by the fact that the uses of more aren't actually parallel.

In more lines of code, the noun phrase is lines of code. The principal noun is lines, so there are more lines. The prepositional phrase of code gives you additional information about the lines.

In more state, the noun phrase is simply the noun state.

With more complex flow control, you can parse it in one of two ways. Either it is more plus a noun phrase complex flow control, meaning that there is a greater amount of complex flow control, or it is an adjective phrase more complex modifying the noun phrase flow control. I find the second interpretation more likely, but either makes sense here. A careful writer who intends the second meaning would probably write more-complex flow control to remove the ambiguity.

Correct answer by phoog on October 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP