> For the complete documentation index, see [llms.txt](https://petozoltan.gitbook.io/simplecode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://petozoltan.gitbook.io/simplecode/clean-code/clean-code-outline/code-formatting.md).

# Code Formatting

### Rules

* Increases readability and expressiveness
* Put close to each other what belongs together

### Vertical

* Member variable declarations at the top of the class
* Local variable declarations prior to their usage - *not at the top of the block*
* Use empty lines - *but only one*
* Write in order of execution and calls
* Write similar methods close to each other

### Horizontal

* Limit line length - *100-120 characters*
* The reader should not scroll to the right
* Use white space
* Use correct indentation
* Do not use tabular formatting

### Blocks

* Always put braces
* Always put braces for empty blocks too

### Good practices

* Agree on formatting in project
* Use your IDE's capabilities - *default is often good*
* Break long expressions into more lines
* Do not deviate too much from Java Code Conventions (Sun, 1997)
