Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: [Original edit by ham1]

...

  • 4 spaces for indentation
    • No tabs (warning)
  • "Soft" maximum line length of ~80 characters
    • Editors and monitors used by most programmers with good eyes can easily handle 120 characters. However:
      • lines longer than this can be harder to read and frustrating work with
      • not all programmers have good eyes and/or wide high resolution monitors
      • in typography line length is recommended to be 45-75 with the optimum being 66 or 45-90
    • Here is an example from CLUtil.java
      • which do you find easier to read?
      • also interesting to note that by looking at long lines we've spotted a simplification/refactor
No Format
            boolean argumentOptional = (flags & CLOptionDescriptor.ARGUMENT_OPTIONAL) == CLOptionDescriptor.ARGUMENT_OPTIONAL;
            boolean argumentRequired = (flags & CLOptionDescriptor.ARGUMENT_REQUIRED) == CLOptionDescriptor.ARGUMENT_REQUIRED;
            boolean twoArgumentsRequired = (flags & CLOptionDescriptor.ARGUMENTS_REQUIRED_2) == CLOptionDescriptor.ARGUMENTS_REQUIRED_2;

...

No Format
            boolean argumentOptional = isFlagSet(flags, == ARGUMENT_OPTIONAL);
            boolean argumentRequired = isFlagSet(flags, == ARGUMENT_REQUIRED);
            boolean twoArgumentsRequired = isFlagSet(flags, == ARGUMENTS_REQUIRED_2);

            private static boolean isFlagSet(int flags, int flag) {
                return (flags & flag) == flag;
            }
  • "Hard" maximum line length of 120 characters
    • Except for imports or other places where breaking the line wouldn't aid readability

...