re: What programming best practice do you disagree with? VIEW POST

FULL DISCUSSION
 

C# Style guidelines. I don't like having the opening bracer on its own line:

Don't like

public static void DoTheThing()
{
   Thing theThing = new Thing();
   theThing.do();
}

Do like

public static void DoTheThing() {
   Thing theThing = new Thing();
   theThing.do();
}

Also, I refuse to have a dangling comma.

const favoriteThings = [
   "whiskers on kittens",
   "bright copper kettles",
   "warm woolen mittens",
   "brown paper packages tied up with strings",
];

Ugh. No. Gross. I think internally it makes my brain expect something to follow the last item, but nothing does.

 

For functions and methods, including anonymous lambda functions, I keep the opening brace on the next line by itself. For objects and everything I put the opening brace on the line with the declaration.

Will 'favoriteThings' even compile with that final comma?

 

In JavaScript, the final comma is optional. In many other languages, that might not be the case.

code of conduct - report abuse