Hi there. At our company's Xmas party we had almost a physical fight over one issue: whether or not to allow empty lines in a function/method in our code (c/c++/c#). This is all about just single blank line, for example imagine code like:
private void LoadData()
{
if (!loaded)
return;
DataStore coll;
SqlData s = new SqlData();
if (!s.CallStoredProcedureToStore(out coll, "xy.usp_zzz",...))
return;
dataViewXy.BeginUpdate();
dataViewXy.Items.Clear();
for(int i = 0; i < coll.RowCount; i++)
{
dataViewXy.Items.Add(coll[i]["ID"]);
}
dataViewXy.EndUpdate();
}
this is a nonsensical mix, just to illustrate situation - first block of function loads data, second one fills some kind of data control and the blank line separates them.
One should also have written a comment before each 'block', but the important thing is that the for guys would place a blank line before that comment and the against guys would not.
For: Allows programmer to logically separate pieces of function so it improves readability as some kind visual cues for the eyes to follow
Against: Decreases readability and programmer should use comment for separating pieces of the function instead.
My personal opinion is to allow blank lines in functions, because without them long pieces of code look to me like a never ending stream of lines without any cues about where to find the stuff I'm looking for)