From 911d9f4a7e3020578f4609860d7e5ede422a8f28 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 29 Sep 2017 15:09:18 -0700 Subject: [PATCH] Update Java style guide --- javaguide.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/javaguide.html b/javaguide.html index 59f03dc54..b17142655 100644 --- a/javaguide.html +++ b/javaguide.html @@ -346,11 +346,16 @@

4.3 One statement per line

4.4 Column limit: 100

-

Java code has a column limit of 100 characters. +

Java code has a column limit of 100 characters. A "character" means any Unicode code point. Except as noted below, any line that would exceed this limit must be line-wrapped, as explained in Section 4.5, Line-wrapping.

+

Each Unicode code point counts as one character, even if its display width is +greater or less. For example, if using +fullwidth characters, +you may choose to wrap the line earlier than where this rule strictly requires.

+

Exceptions:

    @@ -551,7 +556,7 @@

    4.6.2 Horizontal whitespace

This rule is never interpreted as requiring or forbidding additional space at the start or -end of a line; it addresses only interior space.

+end of a line; it addresses only interior space.

4.6.3 Horizontal alignment: never required

@@ -623,6 +628,9 @@
4.8.2.1 One variable per declaration

Every variable declaration (field or local) declares only one variable: declarations such as int a, b; are not used.

+

Exception: Multiple variable declarations are acceptable in the header of a +for loop.

+
4.8.2.2 Declared when needed

Local variables are not habitually declared at the start of their containing @@ -842,15 +850,17 @@

5.2.3 Method names

stop.

Underscores may appear in JUnit test method names to separate logical components of the -name. One typical pattern is test<MethodUnderTest>_<state>, -for example testPop_emptyStack. There is no One Correct +name, with each component written in lowerCamelCase. +One typical pattern is <methodUnderTest>_<state>, +for example pop_emptyStack. There is no One Correct Way to name test methods.

5.2.4 Constant names

Constant names use CONSTANT_CASE: all uppercase -letters, with words separated by underscores. But what is a constant, exactly?

+letters, with each word separated from the next by a single underscore. But what is a +constant, exactly?

Constants are static final fields whose contents are deeply immutable and whose methods have no detectable side effects. This includes primitives, Strings, immutable types, and immutable