3

I have the following sentence (it's from a comment in computer code, just ignore the weird bits):

By strong convention when opening a typeOfObject in the view, send in an object like this {blah blah}.

I think there's a comma missing after "convention", but I'm not sure what the English rules for punctuation is in this case. In Swedish, there would have most definitely been a comma there, so maybe I'm just letting that influence me too much?

EDIT: I guess there should maybe also be a colon after "this", or can that be left out?

  • 6
    Punctuation is a matter of style, not grammar or usage. Here there's a slight semantic issue that no one will care about, mostly because no one will read program comments. Without the comma, the convention is restricted to the opening of a typeOfObject; with the comma, the convention might apply more broadly. There's a slight ambiguity in like this. You mean to refer to the blah code segment, but a reader might understand the reference to be to an object. Use as follows: instead of "like this". – deadrat Jan 27 '17 at 9:53
  • 1
    ... And you need at least a colon after as follows. – Edwin Ashworth Jan 27 '17 at 10:30
  • Well, it's a comment that will be parsed to documentation, and that will be read by the teams building widgets for the application. But sure, I'm not asking because people might misunderstand, I'm asking because I'm a stickler for grammar and can't quite let go until I find out the "right way" to do it :) – Adrian Schmidt Jan 27 '17 at 11:00
  • 1
    According to The Punctuation Guide, it seems the comma is in the right place in the original quote. "When a sentence begins with two dependent clauses that both apply to the subsequent independent clause, insert only a single comma after the second dependent clause. 'If you eat a balanced diet and exercise for a few hours each day, you will feel healthier.'" – Adrian Schmidt Jan 27 '17 at 11:04
  • You need a comma to show that everything after the word convention is by convention. Everything starting with 'when' is by convention. – Yosef Baskin Jan 27 '17 at 17:53
2
+100

Your sentence has two elements in question: a relative clause and a prepositional phrase.

The words

when opening a typeOfObject in this view

form a relative clause. It is introduced by the relative adverb "when" and contains the verb "opening."

An introductory relative clause should be separated from the main clause by a comma when it is not essential to the meaning of the sentence. In this case,

Send in an object like this

can be understood completely; the introductory relative clause just adds additional background information. (Grammar Bytes!)

In contrast, the words

By strong convention

form a prepositional phrase. It is introduced by the preposition "by" and contains the object of the preposition "convention."

Purdue OWL suggests that introductory prepositional phrases should only be followed by a comma if they are long (more than five words) or part of a series of prepositional phrases (e.g. "On the windowsill in my bedroom, I placed a terrarium.").

Therefore, you should retain the comma after "view" but do not need another comma after "convention."

Since this answer is long enough as-is, I will leave it to another user to advise you on the "like this" and colon question.

  • Thanks for this answer! I will let the bounty be open for a while before awarding it to anyone, but this answer certainly qualifies. – Adrian Schmidt Feb 1 '17 at 9:42
0

According to The Punctuation Guide, it seems the comma is in the right place in the original quote.

When a sentence begins with two dependent clauses that both apply to the subsequent independent clause, insert only a single comma after the second dependent clause.

If you eat a balanced diet and exercise for a few hours each day, you will feel healthier.

  • This is the closest I've come to an answer so far. I'll add a bounty in the hope of getting a more definitive answer though. – Adrian Schmidt Jan 31 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.