Re: [Vala] Vala Coding Style



On 02/23/2010 04:44 PM, Maria Rodriguez wrote:
I was looking for some advices of vala coding style. Specifically on the
following issues

Personally, I write like this:

[attribute]
public class Thing : GLib.Object {
  private OtherThing[] things;

  public Thing() {
    return;
  }
}

That is:

I indent each new block by two *spaces*, and compress spaces to tabs only when I have 8 spaces. This makes it appear consistent both on screen and when printed on paper, if it ever should need to be printed.

It is probably better to use a constant value for magic numbers, but that's just my preference.

The best answer, however, is write code in a way that you find comfortably readable. Make functions small, use well-named identifiers (including for constants), make the code flow visually on the screen. For me, that means using the block style above, and not the one that you posted (I think that putting each "{" on its own line is ugly and uses too much space inefficiently and makes things harder to read. Lots of people would disagree with me.).

        --- Mike

--
Michael B. Trausch                                    ☎ (404) 492-6475



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]