Sunday, November 25, 2012

MVC-MVVP for Android

Despite being weighed down by Gig posts in the Chicago area from startups with no money, I have been thinking about the UI MVC-MVVP problem set. iOS has had a MVC approach for awhile but on the android java side until interface and annotation and dependency injection performance get fast enough we avoid many interfaces and other bad choices to deal with it instead of facing it head on.

But what if we start with an anti-pattern? And this is where the java knowledge separates the average android developer from the expert android developer. In Java Swing there is an anti-pattern of an event bus that is in fact serving as the callbacks in swing. I say its an anit-pattern because its not the normal way most are use to seeing the commands passed between MVC-MVVP layers.

If we extend this further and have all objects that operate as a command between layers than we have an anti-type MVC-MVVP in that its not heavily using interfaces and the callbacks are event queue based. Why would this be important other than having  a modular approach to application UI development?

Lets review UI optimization techniques:

1. Reduce the levels between parent and child to get to the invalidate and redraw faster.
2. Reduce the dependencies per callback
3. Reduce the number of interfaces as its a performance hit

The above approach directly reduces point 2 and 3 and indirectly reduces point 1. As the first component choice that leaves Square's Otto out of the mix for use as the event bus library.

EventBus by GreenDroid is not bad as it avoids annotations, yeah, but is missing some features. Sounds like I have a set of libraries to build.