Item 20: Prefer interfaces to abstract classes

Advantages Existing classes can easily be reconstructed to implement a new interface. You just need to use implements clause to the class declaration and add the required methods Interfaces are ideal for defining mixins (Example: http://hannesdorfmann.com/android/java-mixins) Interfaces allow for the construction of non-hierarchical type frameworks. They are great for organizing things that don’t fall into a hierarchy

Read More

Item 15: Minimize the accessibility of classes and members

Encapsulation A well-designed component hides all its implementation details, cleanly separating its API from its implementation. Components then communicate only through their APIs and are oblivious to each others’ inner workings. This concept, known as information hiding or encapsulation, is a fundamental tenet of software design. The advantages of encapsulation are as follows: Speeds up

Read More