You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2019/09/16 13:38:16 UTC

[GitHub] [qpid-broker-j] vavrtom commented on a change in pull request #36: QPID-8361: [Broker-J] Create a developer guide for Qpid Broker-J

vavrtom commented on a change in pull request #36: QPID-8361: [Broker-J] Create a developer guide for Qpid Broker-J
URL: https://github.com/apache/qpid-broker-j/pull/36#discussion_r324095413
 
 

 ##########
 File path: doc/developer-guide/src/main/markdown/code-guide.md
 ##########
 @@ -0,0 +1,446 @@
+# Qpid Broker-J Coding Standards
+
+This article documents the standard adopted for Java code in the Qpid project.
+All committers are expected to follow this standard.
+
+## Executive Summary
+
+The main things for layout purposes in the standard are:
+
+ * Indent using four spaces. No tabs.
+ * braces always go on new lines, e.g.
+```java
+if (x == 5)
+{
+    System.out.println("Hello");
+}
+```
+
+rather than
+
+```java
+if (x == 5} {
+    System.out.println("Hello");
+}
+```
+
+Always add braces, e.g.
+
+```java
+    if (x == 5)
+    {
+        System.out.println("Hello");
+    }
+```
+rather than
+
+```java
+if (x == 5}
+    System.out.println("Hello");
+```
+
+Fields prefixed with underscores, e.g. `_messageCount`
+
+Spaces after keywords but no spaces either before or after parentheses in method calls, e.g.
+
+```java
+    if (x == 5)
+```
+
+rather than
+
+```java
+    if(x==5)
+```
+
+but
+
+```java
+    foo.bar(4, 5)
+```
+
+rather than
+
+```java
+    foo.bar( 4, 5 )
+```
+
+## Details
+
+### Introduction
+
+This document describes two types of coding standard:
+
+1. **Mandatory** standards must be followed at all times.
+2. **Recommended** standards should in general be followed but in particular cases may be omitted
+   where the programmer feels that there is a good reason to do so.
+
+Code that does not adhere to mandatory standards will not pass the automated checks
+(or a code review if the guideline is not stylistic).
+
+### Source files
+
+This section defines the general rules associated with the contents of a Java source file and the order
+in which the each part should be presented. No rules on programming style, naming conventions or indentation are given here.
+
+1. Java source files must have a ".java" suffix (this will be enforced by the compiler) [mandatory].
+2. The basename of a Java source file must be the same as the public class defined therein
+   (this will be enforced by the compiler) [mandatory].
+3. Only one class should be defined per source file (except for inner classes and one-shot uses
+   where the non-public class cannot conceivably be used outside of its context) [mandatory].
+4. Source files should not exceed 1500 lines [recommended].
+5. No line in a source file should exceed 120 characters [mandatory].
+6. The sections of a source file should be presented in the following order [mandatory]:
+   * File information comment (see rule 7 below).
+   * Package name (see rules 1 to 3 in the section 2.1 above and rule 8 below).
 
 Review comment:
   Section 2.1 is probably missing

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org