Play Coding Standards

All view file names should be capitalized according to Java class naming conventions.

View files (such as Index.scala.html) are compiled into Java classes (views.html.Index). To conform to Java coding standards, they should be capitalized. See Elements of Java Style, Guideline #18 for more details.

Remember that Java class names consisting of multiple words have internal capitalization. So, ElectricMeter, not Electricmeter.

Unfortunately, the “play new” command generates a template application with lower-case view files, so you must go against the default. Here is an image of a views directory with an offending view file (laird.scala.html):

laird

View files must contain only UTF-8 characters.

View files must contain only UTF-8 characters. You will know immediately that your system contains non-UTF-8 characters because Play will recompile the entire system every time you retrieve a page.

Here is what the console looks like when the system performs a recompilation upon each page request:

recompile-after-each-page

To fix this, you must remove the offending characters from your view files. Fortunately, Eclipse will normally make this very obvious. For example, here is a view file containing non-UTF-8 characters:

non-utf-8

As you can see, Eclipse renders the non-UTF-8 characters as black diamonds with a “?” character inside. Remove these characters and Play will only compile the view files once, upon first loading of the home page of the application. However, this is not the only cause of repeated recompilation. See the next issue.

No files should have a modification date in the future.

If your computer’s clock happens to be off and your play application is processing source files with a modification date in the future, then Play will recompile the system upon each page request. To prevent this from happening in the first place, make sure your computer’s clock is synchronized with a network time server.

Always remove extraneous code and fix JavaDocs.

Before releasing a system based upon a template, be sure to: