Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Java code has a column limit of 140 characters.

1.3 Horizontal alignment is disallowed

...

This rule overrides section 4.6.3 of Google Java Style Guide.

Alignment can aid readability, but it creates problems for future maintenance. So horizontal alignment is disallowed.

1.4 Punctuation

All natural language sentences must follow generally accepted punctuation rules. It also means that every sentence must end with dot (.), exclamation point (!) or question mark (?) depending on sentence semantics. This requirement applies to:

  • Code comments (JavaDoc and regular comments).
  • Any descriptive messages (for example metrics or JMX properties description).
  • Exception messages.
  • Log messages.
  • Console output.

Exclusions:

  • Titles of table rows/columns.
  • Content of table cells if this cell contains status enum-like value (e.g. status), numeric value, named value (e.g. entity name).
  • Header titles at any level (for example, documentation/comments).

2 Nullability annotation usages

...

Based on this statement there are limited uses cases where var keyword is allowed. The var keyword is allowed only in cases where a right part of an assignment expression contains an explicit type of variable, that is for assignments of literals and the result of constructor invocation.

Allowed only for assignments of literals and , result of constructor invocation and explicit casts:

Code Block
languagejava
var i = 42;
var l = 42L;
var s = "Hello";
var list = new ArrayList<Integer>();
var t = (long) l;


Disallowed for all other cases:

Code Block
languagejava
var i = Integer.parseInt("42");
var s = "Hello".substring(0, 3);
var list = Arrays.asList(1, 2, 3);        
var map = getMapping(); // some method invocation
var val = map.get(42);


4 Async API Guidelines

4.1 All async methods should have async  suffix

Async method is a method that returns Future , CompletableFuture , or CompletionStage .

In some cases, both sync and async variants exist, and async  suffix is used to distinguish between them:

Code Block
languagejava
void upsert(@Nullable Transaction tx, R rec);

CompletableFuture<Void> upsertAsync(@Nullable Transaction tx, R rec);

In other cases, only async variant may be present, but it should have the async  suffix anyway.

4.2 Public APIs should return CompletableFuture - not CompletionStage 

Appendix B: Practices

1 Using Stream API

...

Using of 3rd party libraries in production code is prohibited. But there are some exceptions to this rule:

  • JUnit for testtests
  • Netty
  • ScaleCube
  • Swagger annotations for Open API spec 
  • Micronaut as a REST implementation