Development has an element of artistry to it. Not only in how problems are solved but in the code itself. There are different styles to how we format our code to make it readable. Here I am talking about bracketed languages (Sorry Python people).
I personally prefer opening methods and objects on a new line. I find it easier to distinguish the blocks of code:
public String Greeting()
{
System.out.println("Hello, Dave.");
}
{
System.out.println("Hello, Dave.");
}
As opposed to:
public String Greeting() {
System.out.println("Hello, Dave");
}
System.out.println("Hello, Dave");
}
You will also notice I break the rules regarding capitalization as well.
Sure this means my code has more lines but it seems readable to me.
Sure this means my code has more lines but it seems readable to me.
I also tend to use three spaces (Expanded tabs). This probably comes from my Oracle work. But I find it keeps my code within the viewable area more.
I believe that consistency is even more important than adhering to this rule or that rule.
Remember that the ultimate goal is readability.
No comments:
Post a Comment