Skip to content
ilikeorangutans edited this page Mar 20, 2012 · 6 revisions

Java Code

In general, refer to http://en.wikipedia.org/wiki/The_Elements_of_Java_Style , make sure you understand and apply http://en.wikipedia.org/wiki/SOLID_(object-oriented_design).

  • Always implement against interfaces, never concrete types.
  • Write short classes: 100 lines is good, 200 lines is long, and everything beyond has to be split up
  • Avoid deep nesting levels
  • Avoid if-else constructs, consider breaking up into smaller classes or guardians.
  • Extend java.lang.RuntimeException. Unchecked exceptions are much easier to handle and organize. Make all exceptions inherit ObjectMapperException.
  • Write comments. If you add a class or an interface, at least add a line saying what problem this class solves, even if it's absolutely clear to you.
    • Use JavaDoc style comments before classes, fields and methods
    • Use double slash comments for inline comments
    • Don't comment the obvious.
    • Write comments that
  • Format your code, use the supplied eclipse formatter settings.
  • Organize your imports

API

  • Do not touch the API in core/api unless you have a really good reason for it.
  • Everything in core/api is independent of the actual persistence backends. Never ever add dependencies to concrete persistence subsystems.
  • Be considerate with external dependencies. Be aware of transitive dependencies. We're building a library and we don't want to invade projects with a whole host of dependencies.
Clone this wiki locally