droidcon 2013: Unifying Callbacks in Android; Matt Brenner, UnME2
Channel: droidcon
Date: 25/04/2013

Unifying Callbacks in Android with the (new) "Event Consumer" Design Pattern; Matt Brenner, UnME2

Callbacks are an essential ingredient in modern software development. In Java, callbacks commonly occur within processes: 1. between threads 2. to decouple domain/interface (e.g. Observer Pattern) Android also makes extensive use of, 3. Intents which oftentimes also perform callbacks (e.g. to allow one Activity to invoke another and get back a value). Multiple callbacks in various forms lead to: * interface "clutter" (many Interfaces are defined just to facilitate callbacks) * multiple callback forms in a single class * Intent syntax is clunky and repetitious I have created (and extensively used) a design pattern, "Event Consumer," which unifies callbacks in Android. Naturally, I have developed a set of UML diagrams which presents Event Consumer graphically, but cannot be included in this document. I have also create a set of slides which I will use to present Event Consumer, explain its motivation and need, and demonstrate its use and implementation. Event Consumer is powerful and useful. It arose from my own practical needs. When I began Android development and started using Intents I was surprised at the amount of repetitive code I had to write to set up and launch intents, and to retrieve returned values. Gradually, I developed Event Consumer, which includes, for example, a class (SuperActivity) to insert between Android's Activity and and app-specific Activity sub-classes.

http://de.droidcon.com/2013/sessnio/unifying-callbacks-android-new-event-consumer-design-pattern