1

Let's say I prepared a class which does something for me and I want to put a description of it just above it's definition:

/* My description here */
class myClass
{
  // my code
};

Which description is appropriate?

  1. A Class prepared to do something.

  2. The Class prepared to do something.

  3. (-) Class prepared to do something.

I wouldn't choose the first option, because I mean a specific class that is defined below.

I wouldn't choose the second option, because I prepared a class, it just doesn't seem right to me. When I was working on the class, I didn't have the code in mind, this is just a result of my work.

The third option is wrong, because I need an article since class is a countable noun.

So, which article should I choose and why?

2
  • 1
    What about "this class"? That definitely expresses that what follows the description is the class you're referring to.
    – JMB
    Mar 8, 2016 at 10:38
  • 3
    I agree with JMB. Furthermore, I would drop the ''prepared to" and just say "This class does X, Y and Z".
    – JavaLatte
    Mar 8, 2016 at 10:39

2 Answers 2

2

To directly answer your question: Either "a" or "the" could be appropriate.

"A" means it is one of many possible things. In this case, you would be saying, "here is a class that does X". That is, there may be many classes in this program that do some variety of X. This is one of them. Or more likely, there may be many classes in the world that do X. This is one of them. Think of other context. You might say, "Bob is a friend of mine." Of course Bob is one specific person, but he is not your only friend, certainly not the only person in the world who is someone's friend. So when you first mention him, you call him "a friend", not "the friend".

"The" means one specific thing. We use "the" when the specific thing has already been identified, is obvious from context, or is the only one in the world, or at least in the scope of the conversation. In this case, if this is the only class in your program that does X, you could say, "The class that does X". The fact that there are other classes in other programs that also do X is something that you are considering irrevelant.

All that said, for a comment in a program, I normally wouldn't use either. I usually write comments on or within functions as imperatives. For example, "Calculate sales tax." "Send the confirmation email to the customer." For classes, I describe the thing they represent, usually not using complete sentences. "An item that is stored in the warehouse. Does not include items on the shelves in the stores." This is brief and to the point. It's not necessary to say, "I prepared this class to calculate the sales tax." Of course it's a class, the reader can tell that from the "class" declaration. You don't need to say "prepared to do". As opposed to what? I discovered it lying on the ground on my way to work? :-) Program comments are often more like headlines than full sentences. This isn't an essay, just a hint to other programmers who have to read this thing.

1
  • Indeed, the OP actually correctly uses the indefinite article in his or her sentence Let's say I prepared a class which does something for me. Mar 8, 2016 at 14:59
-1

If you are writing the description right under the class created, place the definite article 'the' by all means!

Why? Because you are writing about that specific class right under it.

However, if you are describing it in a general way, use the indefinite article.

Example:

You are in a class teaching students about how to write a code. You may say...

A class is prepared to make software work.

Now, you already wrote an example of a class. It's right there on the screen and in front of your students.

/* How to print */
class myClass
{
// f(print)
};

Here you say-

The class is made/written to give a 'print command'

Side note: Okay, it is worth mentioning that a very general rule of using indefinite/definite article can also be applied. If you are introducing 'class' for the very first time, use 'a class'. Once it is defined and students know about it, use 'the class'.

[Note: pardon my code. I don't know programming!]

2
  • 1
    You mentioned many ways of refering to a class: what to do if I want to put some descripion under my class definition or if I introduce my class to someone else. But none of that answers my question. I'd like to know what I should do in this specific case - when my description is above my class definition. Mar 8, 2016 at 13:55
  • If you want to introduce, it takes an indefinite article. Something like - A machine is something that works automatically and lessens the human efforts.
    – Maulik V
    Mar 9, 2016 at 4:40

You must log in to answer this question.

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