Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 3.79 KB

Code_Style_and_Guidelines.md

File metadata and controls

20 lines (15 loc) · 3.79 KB

Code Style and Guidelines

Please follow the following rules when working on MapTool. Failure to follow these will typically result in your patch being rejected.

For now patches should be posted to the Testers forum. Access to that forum is by request only; send a PM to jfrazierjr here on the forums and he'll add you to the group. You may then visit that hidden forum and review information on how to post patches for submission.

  1. Thou shalt always highlight the content of any Java source code thee hath modified and select Source -> Format. Note: this requires that the user reset the line length in the Eclipse properties: Trevor wants the line length set to 200 characters. (But see the attached preferences import file as the formatting settings are implemented there.)
  2. Thou shalt always select Source -> Reorganize Imports.
  3. Thou shalt always submit code that includes Javadoc comments for public classes and methods. (T'would be nice to require full Javadoc for everything, but alas, that is unlikely.)
  4. Thou shalt always use the /* */ style of comments in front of classes and methods and may use single-line comments in front of member variables and small snippets of code, but See Rule #3!
  5. Thou shalt always use parameter names different from member field names so that disambiguation using this is not necessary. (Exception: code generated by Eclipse's Source menu items is exempt from this requirement as a productivity enhancement.)
  6. Thou shalt always clearly delineate private constructors with comments so that those who come after thee may retain thy sanity.
  7. Thou shalt never use hard-coded strings in code when a property from an external file can be used. (In MapTool's case, this means calling I18N.getText(propertyKey) and adding a definition for the propertyKey to i18n.properties. Also, all of the show*() methods in MapTool, such as showError() and showWarning(), take propertyKeys as well as strings -- only use propertyKeys!)
  8. Thou shalt always use static final String when hard-coded strings are appropriate. Examples include resources that are embedded inside the MapTool JAR, such as unknown.png -- the question mark image. Other image names that may be considered part of the "theme", such as toolbar images, button images, and so forth, should be retrieved from an images property file; I propose images.properties since we already have sounds.properties. A string in the code should reference a pathname in the property file.
  9. Thou shalt report all exceptions that are true errors. InterruptedException while waiting for a timer can be ignored, for example. But all other errors should be handled by calling MapTool.showError(propertyKey) or similar and passing both a propertyKey and the Throwable object representing the exception. Note that the various "show" methods already provide logging to the .maptool/log.txt file, but separate logging should be performed in the class if possible, since the XML configuration is an all-or-nothing for net.rptools.maptool.client.MapTool.
  10. Thou shalt always use defined properties instead of hard-coded strings when possible. Such as File.separator instead of "/" and now AppActions.menuShortcut instead of "ctrl".

There are surely others that you (the contributors) may want added and that we (the dev team) determine to be acceptable. Please speak up. :)

An exported set of Eclipse Preferences as a ZIP file is available here. Unpack the ZIP and use File > Import... to read them. These preferences only include Java appearance and style-related settings, plus Task tag definitions. (Keyboard shortcuts and other settings are left untouched.)