What FP taught me about OO: Liskov Substitution Principle explained

TL;DR – functional programming taught me that LSP is a special case of PLS: Principle of Least Surprise. One thing that bugs me while reading Java: I’m reading along, come to a method call, ctrl-click on the method name, and get a list of implementations of the interface. IntelliJ can’t tell me exactly what will …

Read moreWhat FP taught me about OO: Liskov Substitution Principle explained

using checkstyle in gradle

The checkstyle plugin brings code quality checks into the gradle build. This way, if team members are using disparate IDEs or have different settings, consistent coding standards are enforced in the build. Here’s how to add checkstyle to your Java build in two steps:1) In build.gradle, add this:     apply plugin: ‘checkstyle’    checkstyle …

Read moreusing checkstyle in gradle

Android: Confirmation Dialog

Warning! This technique is suited to Android API Level 8-10 (Gingerbread). For Honeycomb or newer, use DialogFragment. Problem: my activity knows how to do something (delete a picture), but it needs to ask the user for confirmation first. Solution: pop a confirmation dialog, whose “yes” button responds by deleting the picture. Code:For the very simplest …

Read moreAndroid: Confirmation Dialog