Scala Style Guide

Scala does not have an of­fi­cial style guide yet. Be­cause of this, Daniel Spiewak pos­ted such a doc­u­ment in Novem­ber 2009 on the Scala mail­ing list. As can be read there, even Mar­tin Oder­sky, the in­ventor of Scala, likes that idea and thinks about pub­lish­ing the doc­u­ment on the of­fi­cial Scala web­site.

The PDF ver­sion can be down­loaded from the fol­low­ing web­site:
http://www.codecommit.com/scala-style-guide.pdf

An on­line ver­sion is avail­able un­der the fol­low­ing ad­dress:
http://davetron5000.github.com/scala-style/

The style guide is well struc­tured. Each defin­i­tion also con­tains the reason why you should format your code this way. Counter-ex­amples show how un­read­able code be­comes, if you don’t.

Since I’m a pro­ponent of struc­tured cod­ing I can re­com­mend this doc­u­ment to every­one work­ing with Scala. If you’re new to the lan­guage, you should read the style guide very soon to avoid get­ting into “bad habits”. By fol­low­ing the rules from the style guide you can in­crease read­ab­il­ity of your Scala pro­gram which also im­proves ex­tens­ib­il­ity and main­tain­ab­il­ity.


Posted by Michel Krämer
on March, 22nd 2010.