<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to TradamusCodingGuidelines</title><link>https://sourceforge.net/p/tradamus/wiki/TradamusCodingGuidelines/</link><description>Recent changes to TradamusCodingGuidelines</description><atom:link href="https://sourceforge.net/p/tradamus/wiki/TradamusCodingGuidelines/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 06 Oct 2015 20:07:08 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/tradamus/wiki/TradamusCodingGuidelines/feed" rel="self" type="application/rss+xml"/><item><title>TradamusCodingGuidelines modified by Domhnall101</title><link>https://sourceforge.net/p/tradamus/wiki/TradamusCodingGuidelines/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -1,6 +1,8 @@
-## Java Guidelines ##

-### Files ###
+##Tradamus Coding Guidelines
+### Java Guidelines ##
+
+#### Files ###
 A Java file should start with a copyright header of this form:

 ~~~~
@@ -22,12 +24,12 @@

 The copyright notice is followed by the package declaration.  This is followed by the import statements, which are followed by the class declaration.

-### Packages ###
+#### Packages ###
 All code goes into sub-packages of `edu.slu.tradamus`.  Multiple levels of packaging beyond the first are discouraged.

 Imports appear after the copyright notice.  Java JDK imports appear first, followed by imports from third-party libraries, followed by imports from other Tradamus packages.  Within each group, imports are ordered alphabetically.

-### Classes ###
+#### Classes ###
 Class names are camel-case, starting with a capital letter.

 The class declaration should be preceded by a JavaDoc comment describing the class, along with an `@author` annotation.
@@ -47,13 +49,13 @@

 6. nested classes

-### Methods ###
+#### Methods ###
 Method names are camel-case, starting with a lower-case letter.

 The first component of a method name should be a verb.  If the method primarily acts on the object itself, that is sufficient.  If the method acts on another entity or on a portion of the object, that should be indicated as part of the method name.
 e.g. `load()` loads this object, but `loadChildren()` loads this object's children

-### Variables ###
+#### Variables ###
 Variable names are camel-case, starting with a lower-case letter.

 Where part of a name is an abbreviation, it is all upper-case.
@@ -65,13 +67,13 @@
 Local variables and parameters can (and should) use shorter names.
 e.g. `edID` for a local variable holding an edition ID

-### Constants &amp;amp; Enums ###
+#### Constants &amp;amp; Enums ###
 Use of static final variables as constants is encouraged.

 Constant names and enum values are all upper-case, with components separated by underscores.
 e.g. `CONFIRMATION_PENDING`

-### Exceptions ###
+#### Exceptions ###
 Avoid empty catch blocks.  If you have an exception which will never be thrown, an empty catch block is allowed, but the exception should be called "ignored" to indicate that you know what you're doing.
  e.g.

@@ -84,25 +86,25 @@

 In general, exceptions should be caught at a level where they can meaningfully be reported to the end-user.  In Tradamus, they are typically caught in the servlet's `doGet()` or `doPost()` method, where `HttpServletResponse.sendError()` can be called with an appropriate message.

-### Comments ###
+#### Comments ###
 Yes.  JavaDoc comments in particular.

-### Logging ###
+#### Logging ###
 Use of `System.out` is to be avoided.

 Tradamus uses `java.lang.Logging`.  Where a class needs a logger,  it should be declared as follows:
 `   private static final Logger LOG = Logger.getLogger(MyClass.class.getName());`

-## SQL Guidelines ##
+### SQL Guidelines ##

-### Tables ###
+#### Tables ###
 Table name is the plural form of the entity being stored, in lower case.
 e.g. `projects`, not `project`

 If the table name consists of multiple words, they should be separated by underscores.
 e.g. `group_members`

-### Keys ###
+#### Keys ###
 Tables generally have an auto-increment primary key called `id` of type int(11).

 Foreign keys are generally linked using the `id` field of the foreign table, and have the name of the linked entity.
@@ -116,13 +118,13 @@
 e.g. each image is the child of a canvas, so the `images` table has this constraint:
 ``CONSTRAINT `image_canvas` FOREIGN KEY (`canvas`) REFERENCES `canvasses` (`id`) ON DELETE CASCADE``

-### Columns ###
+#### Columns ###
 Column names are in lower case, separated by underscores.
 e.g. `target_type`

 Where appropriate, use of enums is encouraged.  

-## Web-app Guidelines ##
+### Web-app Guidelines ##
 The general approach is resource-based.  Each endpoint corresponds to a resource which is being manipulated:

 GET `/entity/`*entID* retrieves the given entity
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Domhnall101</dc:creator><pubDate>Tue, 06 Oct 2015 20:07:08 -0000</pubDate><guid>https://sourceforge.net9085b2b6cef26736d15bcfd389e95124781f291b</guid></item><item><title>Tradamus Coding Guidelines modified by Eric Smith</title><link>https://sourceforge.net/p/tradamus/wiki/Tradamus%2520Coding%2520Guidelines/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -20,7 +20,7 @@
  */
 ~~~~

-The copyright notice is followed by the package declaration.  This is followed by the import statements, which is followed by the class declaration.
+The copyright notice is followed by the package declaration.  This is followed by the import statements, which are followed by the class declaration.

 ### Packages ###
 All code goes into sub-packages of `edu.slu.tradamus`.  Multiple levels of packaging beyond the first are discouraged.
@@ -30,6 +30,8 @@
 ### Classes ###
 Class names are camel-case, starting with a capital letter.

+The class declaration should be preceded by a JavaDoc comment describing the class, along with an `@author` annotation.
+
 Within the class declaration the following is the recommended order:

 1. private variables
@@ -38,7 +40,7 @@

 3. methods which operate on the object as a whole, ordered alphabetically

-4. methods which operate on another entity, ordered by entity.
+4. methods which operate on another entity, ordered alphabetically by entity
 e.g. `deleteChildren()` and `loadChildren()` appear before `getEdition()`

 5. static variables, including static final constants
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eric Smith</dc:creator><pubDate>Tue, 17 Jun 2014 20:31:54 -0000</pubDate><guid>https://sourceforge.net0719707659130e09c2f1a7ba2f497d2361515d75</guid></item><item><title>Tradamus Coding Guidelines modified by Eric Smith</title><link>https://sourceforge.net/p/tradamus/wiki/Tradamus%2520Coding%2520Guidelines/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -22,6 +22,14 @@

 The copyright notice is followed by the package declaration.  This is followed by the import statements, which is followed by the class declaration.

+### Packages ###
+All code goes into sub-packages of `edu.slu.tradamus`.  Multiple levels of packaging beyond the first are discouraged.
+
+Imports appear after the copyright notice.  Java JDK imports appear first, followed by imports from third-party libraries, followed by imports from other Tradamus packages.  Within each group, imports are ordered alphabetically.
+
+### Classes ###
+Class names are camel-case, starting with a capital letter.
+
 Within the class declaration the following is the recommended order:

 1. private variables
@@ -36,14 +44,6 @@
 5. static variables, including static final constants

 6. nested classes
-
-### Packages ###
-All code goes into sub-packages of `edu.slu.tradamus`.  Multiple levels of packaging beyond the first are discouraged.
-
-Imports appear after the copyright notice.  Java JDK imports appear first, followed by imports from third-party libraries, followed by imports from other Tradamus packages.  Within each group, imports are ordered alphabetically.
-
-### Classes ###
-Class names are camel-case, starting with a capital letter.

 ### Methods ###
 Method names are camel-case, starting with a lower-case letter.
@@ -60,13 +60,13 @@
 Member variables get spelled out in full.
 e.g. `currentEdition`, not `curEdition`

-Local variables and parameters should use shorter names.
-e.g. `edID` for an edition ID
+Local variables and parameters can (and should) use shorter names.
+e.g. `edID` for a local variable holding an edition ID

 ### Constants &amp; Enums ###
 Use of static final variables as constants is encouraged.

-Enum values are all upper-case, with components separated by underscores.
+Constant names and enum values are all upper-case, with components separated by underscores.
 e.g. `CONFIRMATION_PENDING`

 ### Exceptions ###
@@ -91,7 +91,7 @@
 Tradamus uses `java.lang.Logging`.  Where a class needs a logger,  it should be declared as follows:
 `   private static final Logger LOG = Logger.getLogger(MyClass.class.getName());`

-## SQL Standards ##
+## SQL Guidelines ##

 ### Tables ###
 Table name is the plural form of the entity being stored, in lower case.
@@ -106,13 +106,21 @@
 Foreign keys are generally linked using the `id` field of the foreign table, and have the name of the linked entity.
 e.g. in the `witnesses` table, the edition to which the witness belongs is stored in the `edition` column

+Where possible, use constraints to manage foreign key relationships.
+e.g. canvasses are linked to pages as follows:
+``CONSTRAINT `canvas_page` FOREIGN KEY (`page`) REFERENCES `pages` (`id`) ON DELETE SET NULL``
+
+Child entities should take advantage of the `ON DELETE CASCADE` feature to make it easier to clean up.
+e.g. each image is the child of a canvas, so the `images` table has this constraint:
+``CONSTRAINT `image_canvas` FOREIGN KEY (`canvas`) REFERENCES `canvasses` (`id`) ON DELETE CASCADE``
+
 ### Columns ###
 Column names are in lower case, separated by underscores.
 e.g. `target_type`

 Where appropriate, use of enums is encouraged.  

-## Web-app Standards ##
+## Web-app Guidelines ##
 The general approach is resource-based.  Each endpoint corresponds to a resource which is being manipulated:

 GET `/entity/`*entID* retrieves the given entity
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eric Smith</dc:creator><pubDate>Tue, 17 Jun 2014 20:29:44 -0000</pubDate><guid>https://sourceforge.net503a5be50ce7cd7e76d8fb9263d89804c8c7267e</guid></item><item><title>Tradamus Coding Guidelines modified by Eric Smith</title><link>https://sourceforge.net/p/tradamus/wiki/Tradamus%2520Coding%2520Guidelines/</link><description>&lt;div class="markdown_content"&gt;&lt;h2 id="java-guidelines"&gt;Java Guidelines&lt;/h2&gt;
&lt;h3 id="files"&gt;Files&lt;/h3&gt;
&lt;p&gt;A Java file should start with a copyright header of this form:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="cm"&gt;/*&lt;/span&gt;
&lt;span class="cm"&gt; * Copyright 2011-2014 Saint Louis University. Licensed under the&lt;/span&gt;
&lt;span class="cm"&gt; *    Educational Community License, Version 2.0 (the &amp;quot;License&amp;quot;); you may&lt;/span&gt;
&lt;span class="cm"&gt; * not use this file except in compliance with the License. You may&lt;/span&gt;
&lt;span class="cm"&gt; * obtain a copy of the License at&lt;/span&gt;
&lt;span class="cm"&gt; *&lt;/span&gt;
&lt;span class="cm"&gt; * http://www.osedu.org/licenses/ECL-2.0&lt;/span&gt;
&lt;span class="cm"&gt; *&lt;/span&gt;
&lt;span class="cm"&gt; * Unless required by applicable law or agreed to in writing,&lt;/span&gt;
&lt;span class="cm"&gt; * software distributed under the License is distributed on an &amp;quot;AS IS&amp;quot;&lt;/span&gt;
&lt;span class="cm"&gt; * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express&lt;/span&gt;
&lt;span class="cm"&gt; * or implied. See the License for the specific language governing&lt;/span&gt;
&lt;span class="cm"&gt; * permissions and limitations under the License.&lt;/span&gt;
&lt;span class="cm"&gt; */&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The copyright notice is followed by the package declaration.  This is followed by the import statements, which is followed by the class declaration.&lt;/p&gt;
&lt;p&gt;Within the class declaration the following is the recommended order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;private variables&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;constructors&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;methods which operate on the object as a whole, ordered alphabetically&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;methods which operate on another entity, ordered by entity.&lt;br /&gt;
e.g. &lt;code&gt;deleteChildren()&lt;/code&gt; and &lt;code&gt;loadChildren()&lt;/code&gt; appear before &lt;code&gt;getEdition()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;static variables, including static final constants&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;nested classes&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="packages"&gt;Packages&lt;/h3&gt;
&lt;p&gt;All code goes into sub-packages of &lt;code&gt;edu.slu.tradamus&lt;/code&gt;.  Multiple levels of packaging beyond the first are discouraged.&lt;/p&gt;
&lt;p&gt;Imports appear after the copyright notice.  Java JDK imports appear first, followed by imports from third-party libraries, followed by imports from other Tradamus packages.  Within each group, imports are ordered alphabetically.&lt;/p&gt;
&lt;h3 id="classes"&gt;Classes&lt;/h3&gt;
&lt;p&gt;Class names are camel-case, starting with a capital letter.&lt;/p&gt;
&lt;h3 id="methods"&gt;Methods&lt;/h3&gt;
&lt;p&gt;Method names are camel-case, starting with a lower-case letter.&lt;/p&gt;
&lt;p&gt;The first component of a method name should be a verb.  If the method primarily acts on the object itself, that is sufficient.  If the method acts on another entity or on a portion of the object, that should be indicated as part of the method name.&lt;br /&gt;
e.g. &lt;code&gt;load()&lt;/code&gt; loads this object, but &lt;code&gt;loadChildren()&lt;/code&gt; loads this object's children&lt;/p&gt;
&lt;h3 id="variables"&gt;Variables&lt;/h3&gt;
&lt;p&gt;Variable names are camel-case, starting with a lower-case letter.&lt;/p&gt;
&lt;p&gt;Where part of a name is an abbreviation, it is all upper-case.&lt;br /&gt;
e.g. &lt;code&gt;editionID&lt;/code&gt;, not &lt;code&gt;editionId&lt;/code&gt;; &lt;code&gt;getURL&lt;/code&gt;, not &lt;code&gt;getUrl&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Member variables get spelled out in full.&lt;br /&gt;
e.g. &lt;code&gt;currentEdition&lt;/code&gt;, not &lt;code&gt;curEdition&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Local variables and parameters should use shorter names.&lt;br /&gt;
e.g. &lt;code&gt;edID&lt;/code&gt; for an edition ID&lt;/p&gt;
&lt;h3 id="constants-enums"&gt;Constants &amp;amp; Enums&lt;/h3&gt;
&lt;p&gt;Use of static final variables as constants is encouraged.&lt;/p&gt;
&lt;p&gt;Enum values are all upper-case, with components separated by underscores.&lt;br /&gt;
e.g. &lt;code&gt;CONFIRMATION_PENDING&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="exceptions"&gt;Exceptions&lt;/h3&gt;
&lt;p&gt;Avoid empty catch blocks.  If you have an exception which will never be thrown, an empty catch block is allowed, but the exception should be called "ignored" to indicate that you know what you're doing.&lt;br /&gt;
 e.g.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;   &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;JsonProcessingException&lt;/span&gt; &lt;span class="n"&gt;ignored&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Just writing a Map out as a JSON string.&lt;/span&gt;
   &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In general, exceptions should be caught at a level where they can meaningfully be reported to the end-user.  In Tradamus, they are typically caught in the servlet's &lt;code&gt;doGet()&lt;/code&gt; or &lt;code&gt;doPost()&lt;/code&gt; method, where &lt;code&gt;HttpServletResponse.sendError()&lt;/code&gt; can be called with an appropriate message.&lt;/p&gt;
&lt;h3 id="comments"&gt;Comments&lt;/h3&gt;
&lt;p&gt;Yes.  JavaDoc comments in particular.&lt;/p&gt;
&lt;h3 id="logging"&gt;Logging&lt;/h3&gt;
&lt;p&gt;Use of &lt;code&gt;System.out&lt;/code&gt; is to be avoided.&lt;/p&gt;
&lt;p&gt;Tradamus uses &lt;code&gt;java.lang.Logging&lt;/code&gt;.  Where a class needs a logger,  it should be declared as follows:&lt;br /&gt;
&lt;code&gt;private static final Logger LOG = Logger.getLogger(MyClass.class.getName());&lt;/code&gt;&lt;/p&gt;
&lt;h2 id="sql-standards"&gt;SQL Standards&lt;/h2&gt;
&lt;h3 id="tables"&gt;Tables&lt;/h3&gt;
&lt;p&gt;Table name is the plural form of the entity being stored, in lower case.&lt;br /&gt;
e.g. &lt;code&gt;projects&lt;/code&gt;, not &lt;code&gt;project&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If the table name consists of multiple words, they should be separated by underscores.&lt;br /&gt;
e.g. &lt;code&gt;group_members&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="keys"&gt;Keys&lt;/h3&gt;
&lt;p&gt;Tables generally have an auto-increment primary key called &lt;code&gt;id&lt;/code&gt; of type int(11).&lt;/p&gt;
&lt;p&gt;Foreign keys are generally linked using the &lt;code&gt;id&lt;/code&gt; field of the foreign table, and have the name of the linked entity.&lt;br /&gt;
e.g. in the &lt;code&gt;witnesses&lt;/code&gt; table, the edition to which the witness belongs is stored in the &lt;code&gt;edition&lt;/code&gt; column&lt;/p&gt;
&lt;h3 id="columns"&gt;Columns&lt;/h3&gt;
&lt;p&gt;Column names are in lower case, separated by underscores.&lt;br /&gt;
e.g. &lt;code&gt;target_type&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Where appropriate, use of enums is encouraged.&lt;br /&gt;
&lt;/p&gt;
&lt;h2 id="web-app-standards"&gt;Web-app Standards&lt;/h2&gt;
&lt;p&gt;The general approach is resource-based.  Each endpoint corresponds to a resource which is being manipulated:&lt;/p&gt;
&lt;p&gt;GET &lt;code&gt;/entity/&lt;/code&gt;&lt;em&gt;entID&lt;/em&gt; retrieves the given entity&lt;br /&gt;
POST &lt;code&gt;/entities&lt;/code&gt; creates a new entity&lt;br /&gt;
POST &lt;code&gt;/entity/&lt;/code&gt;&lt;em&gt;entID&lt;/em&gt;&lt;code&gt;/children&lt;/code&gt; creates a new child&lt;br /&gt;
PUT &lt;code&gt;/entity/&lt;/code&gt;&lt;em&gt;entID&lt;/em&gt; updates the given entity, or creates it if it doesn't already exist&lt;br /&gt;
DELETE &lt;code&gt;/entity/&lt;/code&gt;&lt;em&gt;entID&lt;/em&gt; deletes an entity&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eric Smith</dc:creator><pubDate>Tue, 17 Jun 2014 20:09:39 -0000</pubDate><guid>https://sourceforge.net5c4c918e1853f5eb4c2a0dc30f289fec64aa53cc</guid></item></channel></rss>