Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Last active December 3, 2019 21:23
Show Gist options
  • Save bdkosher/5d57d74f5ea6d4dab11406d3ab1ca3a2 to your computer and use it in GitHub Desktop.
Save bdkosher/5d57d74f5ea6d4dab11406d3ab1ca3a2 to your computer and use it in GitHub Desktop.
  • Use Spring Boot
  • Use Lombok
  • Apply the @RequiredArgsConstructor pattern to use constructor injection that feels like field injection
  • Use Java 8 Date/Time API -- do not use java.util.Date or Joda
  • Use Spring Web -- do not attempt to use JAX-RS
  • Do not apply inheritance with your Spring controllers
  • Do not package by layer (and definitely do not put different layers into separate maven sub-modules)
  • Minimize use of for loops. Should be able to get by with Stream API for 95% of use cases
  • Majority of classes should be 20 SLOC or less
  • Inheritance is an ultimately expensive mechanism for code reuse. Composition pattern is better.
  • Instead of passing many arguments, pass a single argument of a custom type with a Builder API (@Builder)
  • Unit test only the public interface
    • Feel free to make internal methods package-private by default and write test cases, but afterwards delete the tests and make the method private (?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment