This document is intended to outline some basic Scala stylistic guidelines which should be followed with more or less fervency. Wherever possible, this guide attempts to detail why a particular style is encouraged and how it relates to other alternatives. As with all style guides, treat this document as a list of rules to be broken. There are certainly times when alternative styles should be preferred over the ones given here.
- Indentation
- Line Wrapping
- Methods with Numerous Arguments
- Naming Conventions
- Classes/Traits
- Objects
- Packages
- Methods
- Constants, Values, Variable and Methods
- Type Parameters (generics)
- Annotations
- Special Note on Brevity
- Types
- Inference
- Annotations
- Ascription
- Functions
- Structural Types
- Nested Blocks
- Curly Braces
- Parentheses
- Declarations
- Classes
- Function Values
- Control Structures
- Curly-Braces
- Comprehensions
- Trivial Conditionals
- Method Invocation
- Arity-0
- Arity-1 (Infix Notation)
- Files
- Multi-Unit Files
- Scaladoc
- General Style
- Packages
- Classes, Objects, and Traits
- Methods and Other Members
Thanks to
Daniel Spiewak and David Copeland for putting this style guide together, and Simon Ochsenreither for converting it to Markdown.
