This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Coding Guidelines
Marvin edited this page Sep 4, 2019
·
9 revisions
This is a small overview of guidelines regarding new and changed code.
All new and changed code must adhere to the Java Code Conventions from Oracle.
Use exactly 4 spaces (no tabs) per level of indentation.
We reserve to be lenient with existing code and arbitrary restrictions regarding row and column counts.
Use your IDE's formatter liberally and regularly. A code style file for IntelliJ exists and matches our preferred style.
Meaning of Importance categorization:
- Must: This guideline has to be adhered to in any new and changed code. No merge is allowed to be accepted with violations to these guidelines.
- Should: You are encouraged to adhere to these guidelines. If you don't adhere to the guidelines, add a comment why this is the case. No merge is allowed to be accepted with violations to these guidelines unless they are accompanied by a valid comment.
Category | Importance | What | Example |
---|---|---|---|
Modern Language Feature | Must | Use lambdas instead of anonymous classes. This improves readability and maintainability | Use () -> {} instead of new Runnable() { ... }
|
Modern Language Feature | Should | Use functional built-in types for lambdas and functional expressions instead of custom counterparts. There are numerous classes that have direct built-in variants in Java | Use Consumer<T> instead of Runnabled<T>
|
Resource Leak | Must | Use try-with-resources when using implementations of AutoClosable that are closed right after using them. This prevents resource leaks and ensures that all resources are returned to the operating system cleanly. |
try(BufferedReader reader = new BufferedReader(new FileReader(path))){ ... } |
Logical Operators | Must | When dealing with logical expressions use the logical operators (or), && (and). This allows for short-circuiting and performance improvements. |
if(true false) { ... }
|
If you have any questions feel free to join our Discord Server / CloudNETService #RELEASE 2.2.0 by CloudNetService
- Home
- Setup
- Servers and Proxys
- Server/Proxy Types
- Signs and Mobs
- Commands
- Template
- Development
- Contributing