Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

building an app to cater for WP7,Iphone & Android

I am about to start building an app that will be used across all platforms. I will using monotouch and monodriod so I can keep things in .net

I'm a little lazy so I want to be able to reuse as much code as possible.

Lets say I want to create an application that stores contact information. e.g. Name & Phone number

My application needs to be able to retrieve data from a web service and also store data locally.

The MVVM pattern looks like the way to go but im not sure my approach below is 100% correct

Is this correct?

  1. A project that contains my models
  2. A project that contains my views,local storage methods and also view models which I bind my views to. In this case there would be 3 different projects based on the 3 os's
  3. A data access layer project that is used for binding to services and local data storage

Any suggestions would be great.

Thanks for your time

like image 975
Diver Dan Avatar asked Mar 22 '11 22:03

Diver Dan


3 Answers

Not specifically answering your question, but here are some lazy pointers...

  • you can definitely reuse a lot of code across all 3 platforms (plus MonoWebOS?!)
  • reusing the code is pretty easy, but you'll need to maintain separate project files for every library on each platform (this can be a chore)
  • MVVM certainly works for WP7. It's not quite as well catered for in MonoTouch and MonoDroid
  • some of the main areas you'll need to code separately for each device are:
    • UI abstractions - each platform has their own idea of "tabs", "lists", "toasts", etc
    • network operations - the System.Net capabilities are slightly different on each
    • file IO
    • multitasking capabilities
    • device interaction (e.g. location, making calls etc)
  • interface abstraction and IoC (Ninject?) could help with all of these
  • The same unit tests should be able to run all 3 platforms?

Update - I can't believe I just stumbled across my own answer... :) In addition to this answer, you might want to look at MonoCross and MvvmCross - and no doubt plenty of other hybrid platforms on the way:

  • https://github.com/slodge/MvvmCross
  • http://monocross.net (MVC Rather then Mvvm)
like image 104
Stuart Avatar answered Oct 24 '22 05:10

Stuart


Jonas Follesoe's cross platform development talk: Has to be the most comprehensive resource out there at the moment. He talks about how best to share code and resources, abstract out much of the UI and UX differences, shows viable reusable usage of MVVM across platforms and nice techniques for putting together an almost automated build. (yes, that includes a way for you to compile you monotouch stuff on Visual Studio)

Best of all he has a available source code for the finished product and for a number of the major component individually placed in its own workshop project and a 50 + page pdf detailing the steps to do so.FlightsNorway on github

IMO the only thing missing is how best to handle local data storage across all platforms. In which case I would direct you to Vici Cool Storage an ORM that can work with WP7, MonoTouch and (while not officially supported) MonoDroid.

*Disclaimer* The site documentation isn't the most updated but the source code is available. (Because documentation is Kriptonite to many a programmer)

like image 41
Terrance Avatar answered Oct 24 '22 04:10

Terrance


I think the easiest way to write the code once and have it work on all three platforms will probably be a web-based application. Check out Untappd for example.

like image 1
Kon Avatar answered Oct 24 '22 04:10

Kon