(Detailed Design) Aleph2 coding and technology conventions - IKANOW/Aleph2 GitHub Wiki

Languages

JVM only

Use Java8/Scala (/possibly Clojure)

Use functional constructs where possible (eg beans should be immutable - see below)

Use guice for dependency injection of shared services

Access Layer applications should use the JAX-RS standard and will likely run in Tomcat7/8 (we are also investigating the play framework). They should use guice (the data_model will provide a utility for injecting the Aleph2 services) via guice-servlet.

null should be avoided - use Optional instead. Use the @NonNull annotation where possible.

Futures should be used where there is any chance of concurrency.

Beans

All database objects should be representing as "pojos" (referred henceforth, not quite accurately, as "beans"):

  • default constructor (plus user constructor)
  • all fields private
  • getters and setters should be in the format "<fieldname>()"/"<fieldname>(T t)" ** (actually setters are discouraged since beans should be immutable, see below)

In addition:

  • immutable (no setters - use data_model.util.ObjectUtils to clone; all collections should be passed through collection.unmodifiableXXX) (more work is needed on handling collection-of-collections immutability)
  • minimize within a bean nesting
  • fields should be "JSON-izable", eg lists, sets, and linkedhashmaps

Jackson should be used for serialization/deserialization.

In interfaces and beans, all function names should be "Drinking Camel Case" eg drinkingCamelCase and all variable names should be "lower case and underscored", eg 'lower_case_and_underscored'

When accessing fields from beans, ObjectUtils should be used together with getter syntax (eg XxxBean::fieldname) vs raw strings ("fieldname"). This is currently not supported for nested fields or maps, so they will have to remain as strings for now.

Project names in contrib

Projects should be called aleph2_<function>_<technology>, eg aleph2_archive_layer_hdfs, aleph2_search_index_layer_elasticsearch etc.

(We may used github submodules for Aleph2 and Aleph2-contrib in the future, to enable per project CI.)

Testing

JUnit and Mockito should be used for testing

In eclipse ecl-emma should be used for code coverage

In github, travis and coveralls (JoCoCo) should be used for continuous integration

⚠️ **GitHub.com Fallback** ⚠️