Skip to content

Latest commit

 

History

History
9 lines (8 loc) · 1.37 KB

theothermattm.md

File metadata and controls

9 lines (8 loc) · 1.37 KB

Matt's Soapbox of Java Practices

  • Use Spring Boot and Spring Initializr to start your project.
    • Spring Boot is everywhere and most java devs tend to know it. If not, it's well documented and easy-ish for others to pick up.
  • Use Lomboc if possible. It will avoid a ton of boilerplate!
  • Prefer the use of a controller layer dedicated to manipulating any HTTP-type objects. Do not let those bleed into any sort of meaningful logic. Separate those out into different Service classes in a separate package.
  • Separate persistence logic into Repository classes in their own package.
  • Mockito is great for being able to unit test your code. Avoid overusing it - If you have a really complicated mock setup, consider refactoring your classes to make them do less things (Single Responsibility Principle principle), or consider instead just writing an integration test to test things together (see below).
  • Use H2 in memory database to create API integration tests against a "real" database. These tests will provide the most bang for the buck and are pretty easy to setup with Spring Boot.