4

I have been developing on Android for a couple months now, and building upon one in house program I found the scalability to be lacking. I have that gut feeling that if I applied some OO Design Patterns I would get an overall better program in speed, scalability, and readability.

Do any of you StackExchangers have ways you've applied a/many design pattern(s) that just seem to fit extremely well with the way Android works?

2 Answers 2

5

I use MVC pattern when developing for Android/Windows Phone 7. Android Views lend themselves pretty well to it and is a great help when keeping the separate. Android code can get pretty complicated tossing views and intents around, so it helps to keep things as compartmentalized as possible.

3
  • 3
    To make this answer more clear: This is how I implemented MVC into Android Projects (I am open for discussion) : Views are saved as XML files in res-directory. Each Activity is a view-controller. Model classes to access data like a Web API e.g. just like in other Java projects. There is nothing like a global controller. Most of global controller logic can be found in the AndroidManifest.xml. Services are good to provide data in the background for several activities. Also see pages on android.com like developer.android.com/guide/topics/fundamentals.html Commented Jan 12, 2011 at 10:12
  • could you give a bit more details on how you implemented mvc? I am familiar with ASP.net mvc but I cant see how to do that here... I still end up with a tightly coupled activity and view.. especially when I wire up the event handlers... Commented Mar 22, 2012 at 12:07
  • @Mel I know it's been a while, but maybe you're still interested and have not come across that good read: therealjoshua.com/2011/11/android-architecture-part-1-intro Commented Apr 16, 2014 at 11:58
0

Patterns aren't really platform-specific; they're about solving a particular issue. So the patterns to apply vary on the type of application. Platforms almost always have baked-in patterns that aren't explicitly mentioned.

You're likely using many patterns without being aware of them (observer, service layers, transaction scripts, active record, controller, factory, etc...). So, perhaps another good question to ask is "What patterns should I understand to take advantage of the Android Platform?", or "What patterns aren't implemented in Android but make development easier?" (which is much more subjective, especially without a firm definition of what it is you're working on.

So perhaps the best answer for you isn't to ask for advice but to do some studying to see what you're using but not acknowledging. Fowler's Patterns of Enterprise Application Architecture is a great read for this--and it's "Cheat Sheet" in the rear-cover is an awesome way to start reading the book.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.