[gnome-boxes] Update CodingStyle
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Update CodingStyle
- Date: Mon, 24 Oct 2011 22:20:27 +0000 (UTC)
commit 884ff9afc80b9d6945cbe510fee3f589d6af6ceb
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Tue Oct 25 00:20:18 2011 +0200
Update CodingStyle
CodingStyle.txt | 85 +++++++++++++++++++------------------------------------
1 files changed, 29 insertions(+), 56 deletions(-)
---
diff --git a/CodingStyle.txt b/CodingStyle.txt
index e82c12a..5f8b364 100644
--- a/CodingStyle.txt
+++ b/CodingStyle.txt
@@ -1,39 +1,25 @@
-Boxes CodingStyle
-=================
+GNOME Boxes Coding Style
+========================
-Coding style is very similar to that of Rygel: https://live.gnome.org/Rygel/CodingStyle
+The coding style to respect in this project is very similar to most
+Vala projects. In particular, the following rules are largely adapted
+from the Rygel Coding Style.
* 4-spaces (and not tabs) for indentation.
- * Each line must be considered 120-columns.
+ * ''Prefer'' lines of less than < 120 columns
- * 1-space between function name and braces (both calls and signature declarations)
+ * 1-space between function name and braces (both calls and signature
+ declarations)
- * Avoid use of 'this' keyword as much as possible:
+ * Avoid the use of 'this' keyword:
- * If function signature/call fits in a single line, do not break it into multiple lines.
+ * If function signature/call fits in a single line, do not break it
+ into multiple lines.
- * If function signature/call doesn't fit in the same line:
- * if the first argument fits on the same line as the previous portion of the call/signature, put it on the first line
- with following comma rest of them on subsequent lines, one-per-line and aligned with the first argument. Like this:
-
- some_object.some_method_call (a,
- b,
- c,
- d,
- e,
- f);
-
- * otherwise, put the opening brace along with the first argument on the second line but indented by 40 columns. The
- rest of the argument follows the same rule as above. Like this:
-
- public void some_method_with_very_long_name
- (int some_argument_with_long_name,
- int another_argument);
-
- * An exception to this rule is made for methods/functions that take variable argument tuples. In that case all the
- first elements of tuples are indented just the normal way described above but the subsequent elements of each tuple
- are indented 4-space more. Like this:
+ * For methods/functions that take variable argument tuples, all the
+ first elements of tuples are indented normally with the subsequent
+ elements of each tuple indented 4-space more. Like this:
action.get ("ObjectID",
typeof (string),
@@ -51,25 +37,8 @@ Coding style is very similar to that of Rygel: https://live.gnome.org/Rygel/Codi
typeof (string),
out this.sort_criteria);
- * Error declarations go on the same line as the last argument if possible, otherwise put it on the next line either
- aligned to the last argument if any or indented by 40 spaces if there are no arguments.
-
- public void some_method (int some_variable_with_long_name,
- int another_variable) throws Error;
- public void some_method (WithAReallyLongSingleArgument arg)
- throws Error;
- public void some_method_with_a_very_long_name_that_throws_error ()
- throws Error;
-
- * When you have to break strings on multiple lines, make use of '+' operator (you can use it on strings in Vala). Like
- this:
-
- // FIXME: This is not recommended by translators, need to clarify Jens Georg
- some_object.some_method ("A very long string" +
- " that doesn't fit " +
- " in one line.");
-
- * ''Prefer'' descriptive names over abbreviations (unless well-known) & shortening of names. E.g discoverer over disco.
+ * ''Prefer'' descriptive names over abbreviations (unless well-known)
+ & shortening of names. E.g discoverer over disco.
* Use 'var' in variable declarations wherever possible.
@@ -77,27 +46,31 @@ Coding style is very similar to that of Rygel: https://live.gnome.org/Rygel/Codi
* Signle statments inside if/else must not be enclosed by '{}'.
- * The more you provide docs in comments, but at the same time avoid over-documenting. Here is an example of useless
- comment:
+ * The more you provide docs in comments, but at the same time avoid
+ over-documenting. Here is an example of useless comment:
// Fetch the document
fetch_the_document ();
- * Each class should go in a separate module (.vala file) & name the modules according to the class in it. E.g
- Boxes.SpiceDisplay class should go under spice-display.vala.
+ * Each class should go in a separate module (.vala file) & name the
+ modules according to the class in it. E.g Boxes.SpiceDisplay class
+ should go under spice-display.vala.
- * Avoid putting more than 3 'using' statements in each module (vala file). If you feel you need to use more, perhaps
- you should consider refactoring (Move some of the code to a separate class).
+ * Avoid putting more than 3 'using' statements in each module (vala
+ file). If you feel you need to use more, perhaps you should
+ consider refactoring (Move some of the code to a separate class).
- * Declare the namespace(s) of the class/errordomain with the class/errordomain itself. Like this:
+ * Declare the namespace(s) of the class/errordomain with the
+ class/errordomain itself. Like this:
- public class Boxes.Hello {
+ private class Boxes.Hello {
...
};
* Prefer 'foreach' over 'for'.
- * Add a newline before each return, break, throw, continue etc. if it is not the only statement in that block:
+ * Add a newline before each return, break, throw, continue etc. if it
+ is not the only statement in that block:
if (condition_applies ()) {
do_something ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]