} void addOnFlipListener(OnFlipListener onFlipListener) { // ...etc... } } • Every listener unique • Code cannot be generalized / built-upon • Every listener requires direct access to Switch • Listenable not something that can be passed around
sum(numbers) == product(numbers); public static int sum(List<Integer> numbers) { int total = 0; Iterator<Integer> it = numbers.iterator(); while(it.hasNext()) { total += it.next(); it.remove(); } return total; }
sum(numbers) == product(numbers); public static int sum(List<Integer> numbers) { int total = 0; Iterator<Integer> it = numbers.iterator(); while(it.hasNext()) { total += it.next(); it.remove(); } return total; }
sum(numbers) == product(numbers); public static int sum(List<Integer> numbers) { int total = 0; Iterator<Integer> it = numbers.iterator(); while(it.hasNext()) { total += it.next(); it.remove(); } return total; } Side effects SUCK