- All source files are encoded in UTF-8.
- If the file contains code points with more than one byte, it must have a UTF-8 byte order mark (BOM).
- Every file containing source code must include copyright and license information.
- The file header format must be based on the CLR JIT Coding Conventions.
- For copyright notices, use the rules described in the GNU Maintainer Information document.
- Additional resources
- How do I apply <SOME OPEN SOURCE LICENSE> to software I'm releasing?
- .NET Foundation discussion about file headers and copyright statements
- The MIT License, Line by Line
- The following rules must be applied for anything that is not specifically stated in this document:
- Formatting
- Four spaces should be used as the unit of indentation
- Column limit: 100 characters
- Lines between 100-110 are perfectly acceptable in many cases where it aids readability and where wrapping has the opposite effect of reducing readability
- When an expression will not fit on a single line, break it after symbols
- The exceptions are the dot separator (
.) and the two colons of a method reference (::), for which the break comes before the symbol
- The exceptions are the dot separator (
- Naming
- When using acronyms and initialisms, define a capitalization that matches the underlying name
and value readability. For example,
httpRequest,HttpRequestandHTTPRequestare all valid names. - Additional resources
- When using acronyms and initialisms, define a capitalization that matches the underlying name
and value readability. For example,
- Optionals
- Avoid null references going in or coming out of protected, package or public methods. Use Optionals instead.
- Don't use optional in fields, method parameters or collections.
- Additional resources
- Uses for Optional (StackOverflow question)
- Should Java 8 getters return optional type? (StackOverflow question)
- Intention Revealing Code With Optional
- The Design of Optional
- 26 Reasons Why Using Optional Correctly Is Not Optional
- Must(read) on Optional(type)
- Java 8 Optional best practices and wrong usage