Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 SOdians have some ways you applied a/many design pattern(s) that just seem to fit extremely well with the way Android works?

share|improve this question

2 Answers 2

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
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 –  OneWorld Jan 12 '11 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... –  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: therealjoshua.com/2011/11/android-architecture-part-1-intro –  Konrad Morawski Apr 16 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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