Slide 8
Slide 8 text
Null checks
• Try to avoid setters - required
dependencies in the constructor
• If an interface is optional, define a
null implementation - no null checks!
• Make use of the @Nonnull and
@Nullable annotations
public interface MessagesCache {
Bitmap getContactPhoto(Contact contact);
void storeContactPhoto(Contact contact, Bitmap bitmap);
void invalidate();
MessagesCache NO_CACHE = new MessagesCache() {
@Override
public Bitmap getContactPhoto(Contact contact) {
return null;
}
@Override
public void storeContactPhoto(Contact contact,
Bitmap bitmap) {
}
@Override
public void invalidate() {
}
};
}