Skip to content

lue-bird/java-coding-style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java by default means

  • mutable objects: person.setName

    • references to mutable objects
      • overriding equals and hashCode
  • statements > expressions:

    doX();
    doY();
  • RuntimeExceptions en masse

  • bad error messages

  • mutable variables: setName(final String name)

  • package public members:

    • private String name;
    • (implicit) constructors
  • extensible classes: final class Person;

  • no exhaustive type matching (only as a java 17 preview feature)

  • eager evaluation

  • unreadable formatting

    • actually useful info near the end of the line:
      public final class <Example> {
          public static void <main(String[] args)> {
              System.out.<println("Hello world")>;
          }
      }
    • all-caps:
      enum Fruit { BANANA }
      static final Fruit YELLOW_FRUIT= BANANA;
    • 1-letter type variable names:
      <T, U, V> V
      map2(...<T> ..., ...<U> ...)
  • verbosity

  • gotchas:

    'h' + 'e' + 'l' + 'l' + 'o' // == 532

... it's easy to write bad code in java.

After a year with elm, I disagree with nearly every basic design decision.

If you are required to use java – just like me, here are some tips to make the best of java:

Note: This list covers only a few tips.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages