Books and Bits: simple service (for social-networking IT book lovers) to provide examples for Object Calisthenics rules.
There are two implementations:
pl.timbercode.books_and_bits.before
contains "dirty" code with// FIXME
comments pointing out broken Object Calisthenics rules.pl.timbercode.books_and_bits.after
contains "clean"code with Object Calisthenics rules applied.
Both implementations share same test cases to make sure they work
in a same way. You can run those test with ./gradlew clean test
command (required JDK 8 or newer).
I've read about Object Calisthenics in following places:
- http://williamdurand.fr/2013/06/03/object-calisthenics
- https://www.cs.helsinki.fi/u/luontola/tdd-2009/ext/ObjectCalisthenics.pdf
As far as I know they were designed Object Oriented programming done in Java (before Java 8), therefore they some of rules probably cannot be applied "as is" in another programming languages and paradigms.
Object Calisthenics rules are:
- Only one level of indentation per method
- Don't use the
else
keyword - Wrap all primitives and strings
- First Class Collections
- One dot per line
- Don't abbreviate
- Keep all entities small
- No classes with more than two instance variables
- No getters/setters/properties