You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by Matt Sicker <bo...@gmail.com> on 2021/06/27 22:18:00 UTC

Thoughts on Java 11 style guide updates?

Since log4j 3.x is based on Java 11, that adds several new features
that we can use. In particular, I've found two syntax additions that
may be useful (besides the various API updates in the standard class
library):

* var keyword for local variables (annoyingly requires the use of "final var")
* private methods on interfaces (static or instance)

So far, I've only found myself using the var keyword in some fairly
limited situations to avoid extra long lines, but not very often. The
private methods on interfaces makes it easier to break up interface
default methods and such without util classes or other workarounds.
There are possibly more features that I'm missing (besides the beta
features that were released in later versions like text blocks),
though most of the Java syntax changes since v8 seem to be in versions
between 12 and 17 (switch expressions, records, pattern matching,
etc.).

Re: Thoughts on Java 11 style guide updates?

Posted by Ralph Goers <ra...@dslextreme.com>.
I would suggest:
a) Looking to see what, if anything, the latest version of Effective Java says.
b) Looking for style guides from others that cover these newer versions of Java to see what they say.

IOW, I don’t think we should adopt our own rules if they are not common practice.

Ralph

> On Jun 27, 2021, at 3:18 PM, Matt Sicker <bo...@gmail.com> wrote:
> 
> Since log4j 3.x is based on Java 11, that adds several new features
> that we can use. In particular, I've found two syntax additions that
> may be useful (besides the various API updates in the standard class
> library):
> 
> * var keyword for local variables (annoyingly requires the use of "final var")
> * private methods on interfaces (static or instance)
> 
> So far, I've only found myself using the var keyword in some fairly
> limited situations to avoid extra long lines, but not very often. The
> private methods on interfaces makes it easier to break up interface
> default methods and such without util classes or other workarounds.
> There are possibly more features that I'm missing (besides the beta
> features that were released in later versions like text blocks),
> though most of the Java syntax changes since v8 seem to be in versions
> between 12 and 17 (switch expressions, records, pattern matching,
> etc.).
>