Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as too broad by amon, Scant Roger, Robert Harvey, Ixrec, gnat Jan 4 at 8:42

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 5 down vote accepted

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.

share|improve this answer
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 like – OneWorld Jan 12 '11 at 10:12
could you give a bit more details on how you implemented mvc? I am familiar with 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... – Mel Mar 22 '12 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: – Konrad Morawski Apr 16 '14 at 11:58

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.