Model View Controller (MVC) for Android
Finally, I have been able to find time to push the intial code for “Model View Controller” implementation on Android.
Quite a few people told me that MVC is inbuilt in Android, with the View being represented by the Activity but I failed to visualize or tangelize the Controller. Well, the Model can always be the backend data – the business entities.
The code is hosted on Sourceforge – https://sourceforge.net/projects/android-mvc/
If are you interested in the code, you can get it using Git at git://android-mvc.git.sourceforge.net/gitroot/android-mvc/android-mvc.
Or if you just want to browse the code before downloading it on your machine, you can visit http://android-mvc.git.sourceforge.net/.
The code, by any means, is not yet ready for production use since I know various pitfalls, specially for the scenarios when the “Command” fetches the data from the network or database or from anywhere that takes long time.
In these cases, the best practice would be to hive-off the execution in a separate thread (read: Non-UI Thread). When the response is ready, you would pass it to the main thread (read: UI Thread) using a Handler. This part is implemented in the Controller, however, there can be race conditions in the scenarios where in multiple commands get issued – specially in very interactive application. Well, the bigger question there can always be – should MVC be used in that specific scenario?
Additionally, since, currently, the progress is presented using another Activity, there is an extra house keeping that is being done and I know (by use of this approach in my application), it is bound to fail in near-extreme scenarios.
The fixes are available with me… and I should soon find time to push them. Besides, I also need to a create more powerful case-study!
So… keep watching!
And yes… if you feel that the code has done any good to you, please do spread the word and “Share the Love”
Here are initial screenshots of a trivial case-study (scenario) of initial implementation…
August 14, 2010
Tags: Android, Architecture, Design, Framework, MVC, Sourceforge, Technology Posted in: Uncategorized




7 Responses
Great points…I would note that as someone who really doesn’t write on blogs much (in fact, this may be my first post), I don’t think the term “lurker” is very flattering to a non-posting reader. It’s not your fault in the least , but perhaps the blogosphere could come up with a better, non-creepy name for the 90% of us that enjoy reading the posts.
Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
Android下的MVC | X文档 - August 23, 2010
[...] MVC实现的初步版本http://blogs.mastergaurav.com/2010/08/14/model-view-controller-mvc-for-android/. [...]
For the help please use http://www.google.com
Hello Android! :) « The Geeky Me - September 16, 2010
[...] 2. Decide what Architectural Design Pattern you should use for your system – I think this is a must in every software project. From what I’ve researched, MVC is the commonly used pattern for mobile applications. However, there are some sources that PAC is also suitable for this kind of system. For now, I’ll just stick with MVC since I’m more familiar with it. I’ll try to understand how to apply this to Android using Mindless Mind’s attempt. [...]
Hi Geeky Me!
I should be publishing a full fledged case-study sometime soon. And that anytime soon can be 2-3 weeks
-Gaurav
HI Gaurav,
I am new for the Android application development.
can u please share user guide how to use your framework.
as i go through with instruction but some where i stuck.
i really thank full if you share detail documentation.
Leave a Reply