<!--
title: Spring code style
domain: app-frameworks
topic: Code Style
language: Java
source: spring-projects/spring-framework
updated: 2024-09-20
url: https://awesomereviewers.com/reviewers/spring-framework-spring-code-style/
-->

Follow Spring Framework's code style guidelines to ensure consistency across the codebase. Key rules include:

1. **Import statements**: 
   - Use specific imports rather than wildcard imports
   - Maintain consistent import ordering
   - Avoid static imports except in specific cases

2. **Field and variable references**:
   - Always prefix instance field references with `this.`
   - Don't declare local variables as `final` unless there's a compelling reason
   - Don't use `var` in production code

3. **Formatting**:
   - Use tabs for indentation, not spaces
   - Remove unnecessary spaces inside parentheses
   - Aim for 90 characters per line (maximum 120), with 80 for Javadoc
   - Place opening braces on the same line, `else` statements on a new line

4. **Before submitting**:
   - Run `./gradlew check` to catch style violations automatically

Example of proper style:
```java
public class MyClass {
    private final String field;

    public MyClass(String parameter) {
        this.field = parameter;
    }

    public void doSomething(String input) {
        if (input == null) {
            return;
        }
        else {
            String result = processInput(this.field, input);
            processResult(result);
        }
    }
}
```
