Curly Brackets
My co-programmers and I have been talking about coding standards within our organisation (the conversations tend to be very civilised as there are only three of us!) The most contentious point has been whether curly brackets for procedures and if/for/foreach/do statements should begin on the same line as the statement or on the line below.
i.e. is this:
public class myPage : System.Web.UI.Page
{
protected void Page_Load(object Sender, EventArgs e)
{
if(Request.QueryString[“category“] != null)
{
Response.Write(Request.QueryString[“category“]);
}
}
}
better than this:
public class myPage : System.Web.UI.Page
{
protected void Page_Load(object Sender, EventArgs e) {
if(Request.QueryString[“category“] != null) {
Response.Write(Request.QueryString[“category“]);
}
}
}
I am inclined to think the former is better because you can immediately tell whether every curly bracket has been closed. The consensus here, however, is that the latter is better because you can immediately tell whether something is a class or an if statement. I'm interested in different justifications for different coding standards so anyone has any ideas please post them to the comments section of this post.