| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| |
| <!-- |
| Copyright 1999-2004 The Apache Software Foundation |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| |
| <!-- Content Stylesheet for Site --> |
| |
| |
| <!-- start the processing --> |
| <!-- ====================================================================== --> |
| <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! --> |
| <!-- Main Page Section --> |
| <!-- ====================================================================== --> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> |
| |
| <meta name="author" value="Velocity Documentation Team"> |
| <meta name="email" value="jvanzyl@zenplex.com"> |
| |
| |
| |
| |
| <title>Velocity - Coding Standards</title> |
| </head> |
| |
| <body bgcolor="#ffffff" text="#000000" link="#525D76"> |
| <table border="0" width="100%" cellspacing="0"> |
| <!-- TOP IMAGE --> |
| <tr> |
| <td align="left"> |
| <a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" border="0"/></a> |
| </td> |
| <td align="right"> |
| <a href="http://jakarta.apache.org/velocity/"><img src="./images/logo.gif" alt="Velocity" border="0"/></a> |
| </td> |
| </tr> |
| </table> |
| <table border="0" width="100%" cellspacing="4"> |
| <tr><td colspan="2"> |
| <hr noshade="" size="1"/> |
| </td></tr> |
| |
| <tr> |
| <!-- LEFT SIDE NAVIGATION --> |
| <td width="20%" valign="top" nowrap="true"> |
| |
| <!-- ============================================================ --> |
| |
| <p><strong>About</strong></p> |
| <ul> |
| <li> <a href="./index.html">Overview</a> |
| </li> |
| <li> <a href="./getting-started.html">Getting Started</a> |
| </li> |
| <li> <a href="http://jakarta.apache.org/builds/jakarta-velocity/">Download</a> |
| </li> |
| <li> <a href="./install.html">Install</a> |
| </li> |
| <li> <a href="./design.html">Design</a> |
| </li> |
| <li> <a href="./contributors.html">Contributors</a> |
| </li> |
| <li> <a href="./changes.html">ChangeLog</a> |
| </li> |
| <li> <a href="./code-standards.html">Coding Standards</a> |
| </li> |
| <li> <a href="./license.html">License</a> |
| </li> |
| <li> <a href="./todo.html">TODO</a> |
| </li> |
| <li> <a href="http://issues.apache.org/bugzilla/enter_bug.cgi?product=Velocity">Report Issues</a> |
| </li> |
| </ul> |
| <p><strong>Community</strong></p> |
| <ul> |
| <li> <a href="./powered.html">Powered By Velocity</a> |
| </li> |
| <li> <a href="http://jakarta.apache.org/site/getinvolved.html">Get Involved</a> |
| </li> |
| <li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a> |
| </li> |
| <li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repositories</a> |
| </li> |
| </ul> |
| <p><strong>Docs</strong></p> |
| <ul> |
| <li> <a href="./user-guide.html">User's Guide (English)</a> |
| </li> |
| <li> <a href="./user-guide_fi.html">User's Guide (Finnish)</a> |
| </li> |
| <li> <a href="./user-guide_fr.html">User's Guide (French)</a> |
| </li> |
| <li> <a href="./user-guide_es.html">User's Guide (Spanish)</a> |
| </li> |
| <li> <a href="./developer-guide.html">Developer's Guide</a> |
| </li> |
| <li> <a href="./vtl-reference-guide.html">VTL Reference Guide</a> |
| </li> |
| <li> <a href="./specification.html">Specification</a> |
| </li> |
| <li> <a href="./api/index.html">Javadoc</a> |
| </li> |
| </ul> |
| <p><strong>Tools</strong></p> |
| <ul> |
| <li> <a href="./tools/index.html">Velocity Tools</a> |
| </li> |
| <li> <a href="./anakia.html">Anakia : XML->doc tool</a> |
| </li> |
| <li> <a href="./texen.html">Texen : text generation</a> |
| </li> |
| <li> <a href="./dvsl/index.html">DVSL : XML xformation</a> |
| </li> |
| <li> <a href="./veltag.html">Veltag : JSP taglib</a> |
| </li> |
| <li> <a href="./migration.html">Migration to Velocity</a> |
| </li> |
| <li> <a href="./devtools.html">Editors and IDEs</a> |
| </li> |
| </ul> |
| <p><strong>Comparisons</strong></p> |
| <ul> |
| <li> <a href="./ymtd/ymtd.html">YMTD</a> |
| </li> |
| <li> <a href="./differences.html">VM/WM Differences</a> |
| </li> |
| <li> <a href="./casestudy1.html">JSP vs. Velocity</a> |
| </li> |
| <li> <a href="./casestudy2.html">XMLC vs. Velocity</a> |
| </li> |
| </ul> |
| <p><strong>Site Translations</strong></p> |
| <ul> |
| <li> <a href="http://jakarta.apache.org/velocity/">English</a> |
| </li> |
| <li> <a href="http://www.ingrid.org/jajakarta/velocity/velocity-1.2-rc2/docs-ja/index.html">Japanese</a> |
| </li> |
| </ul> |
| </td> |
| <td width="80%" align="left" valign="top"> |
| <table border="0" cellspacing="0" cellpadding="2" width="100%"> |
| <tr><td bgcolor="#525D76"> |
| <font color="#ffffff" face="arial,helvetica,sanserif"> |
| <a name="Coding Standards"><strong>Coding Standards</strong></a> |
| </font> |
| </td></tr> |
| <tr><td> |
| <blockquote> |
| <p> |
| This document describes a list of coding conventions that are required |
| for code submissions to the project. By default, the coding conventions |
| for most Open Source Projects should follow the existing coding conventions |
| in the code that you are working on. For example, if the bracket is on |
| the same line as the if statement, then you should write all your code |
| to have that convention. |
| </p> |
| <p> |
| <strong>If you commit code that does not follow these conventions and you |
| are caught, you are responsible for also fixing your own code.</strong> |
| </p> |
| <p> |
| Below is a list of coding conventions that are specific to Velocity, |
| everything else not specificially mentioned here should follow the official |
| <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun |
| Java Coding Conventions</a>. |
| </p> |
| <p> |
| 1. Brackets should begin and end on a new line. Examples: |
| </p> |
| <div align="left"> |
| <table cellspacing="4" cellpadding="0" border="0"> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#ffffff"><pre> |
| |
| if ( foo ) |
| { |
| // code here |
| } |
| |
| try |
| { |
| // code here |
| } |
| catch (Exception bar) |
| { |
| // code here |
| } |
| finally |
| { |
| // code here |
| } |
| |
| while ( true ) |
| { |
| // code here |
| } |
| |
| </pre></td> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| </table> |
| </div> |
| <p> |
| 2. It is <strong>OK</strong> to have spaces between the parens or not. The |
| preference is to not include the extra spaces. For example, both of these are |
| ok: |
| </p> |
| <div align="left"> |
| <table cellspacing="4" cellpadding="0" border="0"> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#ffffff"><pre> |
| |
| if (foo) |
| |
| or |
| |
| if ( foo ) |
| |
| </pre></td> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| </table> |
| </div> |
| <p> |
| 3. 4 spaces. <strong>NO</strong> tabs. Period. We understand that a lot of you |
| like to use tabs, but the fact of the matter is that in a distributed |
| development enviroment, when the cvs commit messages get sent to a mailing list, |
| they are almost impossible to read if you use tabs. |
| </p> |
| <p> |
| In Emacs-speak, this translates to the following command: |
| |
| (setq-default tab-width 4 indent-tabs-mode nil) |
| |
| </p> |
| <p> |
| 4. Unix linefeeds for all .java source code files. Other platform specific |
| files should have the platform specific linefeeds. |
| </p> |
| <p> |
| 5. Javadoc <strong>MUST</strong> exist on all your methods. Also, if you are |
| working on existing code and there currently isn't a javadoc for that |
| method/class/variable or whatever, then you should contribute and add it. |
| This will improve the project as a whole. |
| </p> |
| <p> |
| 6. The <a href="license.html">Apache Software License</a> <strong>MUST</strong> be placed at the top |
| of each and every file. |
| </p> |
| <p> |
| 7. If you contribute to a file (code or documentation), add yourself to the |
| top of the file. For java files the preferred Javadoc format is: |
| </p> |
| <div align="left"> |
| <table cellspacing="4" cellpadding="0" border="0"> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#ffffff"><pre> |
| @author <a href="mailto:user@domain.com">John Doe</a> |
| </pre></td> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| </table> |
| </div> |
| <p> |
| Thanks for your cooperation. |
| </p> |
| </blockquote> |
| </p> |
| </td></tr> |
| <tr><td><br/></td></tr> |
| </table> |
| <table border="0" cellspacing="0" cellpadding="2" width="100%"> |
| <tr><td bgcolor="#525D76"> |
| <font color="#ffffff" face="arial,helvetica,sanserif"> |
| <a name="More Fun For Emacs"><strong>More Fun For Emacs</strong></a> |
| </font> |
| </td></tr> |
| <tr><td> |
| <blockquote> |
| <p> |
| To make coding easier, following bit of Emacs LISP does |
| the 'right thing' with bracing, if you want. |
| </p> |
| <div align="left"> |
| <table cellspacing="4" cellpadding="0" border="0"> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#ffffff"><pre> |
| (defun apache-jakarta-mode () |
| "The Java mode specialization for Apache Jakarta projects." |
| (if (not (assoc "apache-jakarta" c-style-alist)) |
| ;; Define the Apache Jakarta cc-mode style. |
| (c-add-style "apache-jakarta" '("java" (indent-tabs-mode . nil)))) |
| |
| (c-set-style "apache-jakarta") |
| (c-set-offset 'substatement-open 0 nil) |
| (setq mode-name "Apache Jakarta") |
| |
| ;; Turn on syntax highlighting when X is running. |
| (if (boundp 'window-system) |
| (progn (setq font-lock-support-mode 'lazy-lock-mode) |
| (font-lock-mode t)))) |
| |
| ;; Activate Jakarta mode. |
| (if (fboundp 'jde-mode) |
| (add-hook 'jde-mode-hook 'apache-jakarta-mode) |
| (add-hook 'java-mode-hook 'apache-jakarta-mode)) |
| </pre></td> |
| <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| <tr> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td> |
| </tr> |
| </table> |
| </div> |
| <p> |
| Note that this will apply to all java in emacs. |
| To control it : |
| |
| <ul> |
| <li> |
| Turn off : <code>M-: (remove-hook 'java-mode 'apache-jakarta-mode)</code> |
| </li> |
| <li> |
| Turn on : <code>M-: (add-hook 'java-mode 'apache-jakarta-mode)</code> |
| </li> |
| </ul> |
| 'M-:' is <meta> followed by ':', of course. |
| It will be on by default at startup. |
| </p> |
| <p> |
| This was stolen lock, stock and barrel from the contribution |
| to the Turbine project by Daniel L. Rall. Thanks Daniel! |
| </p> |
| </blockquote> |
| </p> |
| </td></tr> |
| <tr><td><br/></td></tr> |
| </table> |
| </td> |
| </tr> |
| |
| <!-- FOOTER --> |
| <tr><td colspan="2"> |
| <hr noshade="" size="1"/> |
| </td></tr> |
| <tr><td colspan="2"> |
| <div align="center"><font color="#525D76" size="-1"><em> |
| Copyright © 1999-2004, The Apache Software Foundation |
| </em></font></div> |
| </td></tr> |
| </table> |
| </body> |
| </html> |
| <!-- end the processing --> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |