# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://petozoltan.gitbook.io/clearcode/clean-code/clean-code-outline/code-formatting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
