0

Every time, I confuse what I need to use: "a" or "the".

I understood that "a" means something abstract, and "the" is used when we talk about something concrete. But, this is my case. I need to write a description of the programming method.

/**
 * Checks that a connection is established.
 * @return true if a connection exists.
 */

In this case, I don't know which article I need to use before "connection" in the first sentence. It must check that connection that belongs to this method is established. So it means that we are talking about (a/the) concrete connection. But this connection in every running of the program will be different.

1 Answer 1

2

The method is a piece of code that has been written and set aside, to be called at any time the main program requires it. It checks for any connection that might happen to exist. So when describing what the method does the indefinite article a is appropriate:

/**
 * Checks that a connection is established.
 * @return true if a connection exists.
 */
bool isConnectionEstablished() {
    #code goes here
}

The first time you interact with the method in the main code you are still checking for any connection and the indefinite article is still appropriate:

#See if there is a connection
bool existsConnection = isConnectionEstablished();

If you call the method again, like if the connection drops and you want to see if it has been re-established, you are then dealing with a specific connection (the one that was checked for previously) and you would use the definite article the, as I did at the beginning of this sentence:

#See if the connection has come back
existsConnection = isConnectionEstablished();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .