# Conventions

### Naming Conventions

* Use **lowerCamelCase** for variables, methods, and fields.
* Use **UpperCamelCase** (PascalCase) for classes and interfaces.
* Constants should be prefixed with 'k'
* Choose descriptive and meaningful names to improve code readability.

### Subsystem Dependencies

* **Subsystems should never directly reference each other.**
* Always use **dependency injection** to provide subsystems with required dependencies.
* This promotes loose coupling and easier unit testing.
* Aim to keep subsystems independent for modularity and maintainability.

### Version Control with Git

* Use Git for managing code versions collaboratively.
* Commit **frequently** with descriptive messages that explain the “why” and “what.”
* Use branches to develop features independently without affecting the main stable code.
* Pull regularly to sync changes from others, resolving conflicts promptly.
* Push your commits to share your work and back up progress.

### Logging

* We use **AdvantageKit logging** for runtime data capture.
* Consistently log important events, state changes, and errors for troubleshooting.
* Avoid excessive logging to prevent clutter and performance issues.

### Formatting and Style

* Use **Prettier** for automatic code formatting to maintain consistent style.
* Consistency in formatting improves readability and reduces merge conflicts.

### Refactoring

* Perform **annual refactoring** of the codebase to improve structure, remove technical debt, and update design patterns.
* Refactoring should not add features but clean up and optimize existing code.

***

## Java Visibility and Keywords

### Visibility Modifiers

Visibility modifiers control access to classes, methods, and variables:

| Modifier    | Accessibility                            | Usage Summary                              |
| ----------- | ---------------------------------------- | ------------------------------------------ |
| `public`    | Accessible from anywhere                 | For APIs or classes intended for wide use. |
| `protected` | Accessible within package and subclasses | For subclass extension points.             |
| *default*   | Accessible within the package only       | For internal package usage.                |
| `private`   | Accessible only within the class         | For encapsulating implementation details.  |

**Best Practice:** Default to the most restrictive visibility possible to maintain encapsulation.
