Anyone have experience with architecture for cross

2019-01-16 09:18发布

This question is specifically related to a recommended architecture and people's previous experiences for cross-platform WP7, iOS, Android apps developed using C#, Monotouch and Monodroid respectively. I have researched previous questions here, here and here. They provide good answers but not quite what I'm looking for. I have also found this excellent question which does go into the cost benefit so there is some overlap.

I have a requirement to develop a cross-platform iPhone/iPad, WP7 and android app for a health & fitness company, which will integrate with their website. The app requires a small amount of local data storage for offline mode and synchronisation with the website when a network is available. I am a Windows (C#/C++) developer through and through and don't really want to go down the route of three Objective C, Java and C# apps, although I will if I have to. I will also be operating as tech lead and farming out some work to a team on this project.

I would like to know if anyone here has experience with cross-platform development using Monotouch, Monodroid and WP7 and to share their experience on application architecture to re-use as much code as possible. The architecture I am considering is as follows:

Proposed architecture for Wp7, Monotouch, Monodroid app

My question is as follows:

  • Has anyone here tried something like this?
  • Are these frameworks (Monotouch, monodroid) worth their salt for this sort of work?
  • Can I setup the entire project in Visual Studio 2010 with separate projects (dlls/exe) for the Monotouch, Monodroid and Wp7 target (but shared code using 'Add as Link')?
  • What sort of code-reuse can I realistically expect with this (or a similar) architecture? i.e. what strategies / patterns can I use to re-use local data access, webservices, and business logic?

Best regards,

4条回答
甜甜的少女心
2楼-- · 2019-01-16 09:21

You might want to look into the MonoCross project which is designed to help you reuse C# code with multiple presentation layers:

http://code.google.com/p/monocross/

The authors of MonoCross (ITR Mobility) have created multiple mobile cross platform solutions for a variety of customers and have written two books on the subject one is "iPad in the Enterprise" (http://amzn.to/zAhQK6) and the upcoming "Cross-Platform Mobile Development with C#" (http://amzn.to/wM6RsF).

In the meantime, you can watch Scott Olson's presentation that he did at Monospace 2011 that describes how to use MonoCross to target multiple mobile and desktop platforms at once reusing the business logic:

http://www.infoq.com/presentations/The-Rise-of-Mono-in-the-Enterprise

They enforce a strict MVC split in their code:

MonoCross MVC Pattern http://tirania.org/s/0e187c1c.png

The biggest benefit of designing an application with this model is that you can run the same application with native user interfaces on each platform. You get native iOS, Android, Windows UI and they even have an ASP.NET front-end that allows you to publish Web versions of the same business logic.

This technology was used successfully by the Medtronic sample app that is showcased by Apple in their iPad business:

http://www.apple.com/ipad/business/profiles/medtronic/

I suggest you also check out Scott's blog where he posts regularly about his experiences with cross-platform architecture.

查看更多
倾城 Initia
3楼-- · 2019-01-16 09:24

Based on your comments your requirements are for a cross-mobile platform that will integrate with their existing services, but also work offline. You are specifically interested in C# via Mono, however you have indicated that you are not discounting other approaches.

I feel that HTML / PhoneGap / JavaScript is a route that you should explore in some detail. The WP7 version of this framework has just been released, and I have had experience of releasing an application to the marketplace using this approach.

PhoneGap wraps your HTML / JavaScript code, in the case of WP7 this is loaded into local storage. This enables the application to work entirely offline. This is true for all versions (iOS, Android etc...)

Probably the biggest issue with PhoneGap / HTML5 is the same issue we have when developing complex web based applications for the browser. The tooling for JavaScript is not great and browser differences are a constant issue. However, it is a tried and tested solution.

Finally, it is possible to create an application UI that is entirely different for each platform. By using the MVVM pattern I have managed to share all my JavaScript business logic between WP7 and iOS applications whilst having a totally different UI:

enter image description here

Compare this to the WP7 screens:

enter image description here

NOTE: I plan to have the iOS version of Property Finder in the AppStore shortly, I just need to work out how to use PhoneGap Build!

查看更多
霸刀☆藐视天下
4楼-- · 2019-01-16 09:30

The question is very hard to answer, yet I would like to share some thoughts.

The situation with the mobile development is very similar to the development at the first half of the 90s. Phone have limited resources as computers had, mobile OSes are making their baby steps, hence the ecosystem is relatively small. They have own philosophy, tools and even languages. And this is a good thing, but leads to a headache for cross-platform development. As a result, there are many attempts to clear this a bit. People build frameworks, wrappers etc. which is a kind of abstraction and abstractions are leaky. This is extremely important for mobile devices not only the performance as numbers of CPU cycles, but also the performance of the battery, which is far more important for the user.

If I were you I would build apps in a native environment especially if you have some performance considerations. Best support, tools, educational resources etc. pays for the duplicated business logic. All in all, it's not a OS or Database Management System, codebase won't be huge ;)

That being said. Regarding Monotouch and Monodroid I would be very careful since Apple blocks iPhone OS apps created by many third-party compilers and The King doesn't really care about developers. The case that mono will be flushed to the toiled by patent infringement or proprietary software vendors is very likely. This is sad for me cause C# is my favorite language.

PS. I don't believe that HTML5 for mobile will take over any time soon.

查看更多
成全新的幸福
5楼-- · 2019-01-16 09:41

Just adding another alternative to the mix - mvvmcross

This project was developed out of experiences with monocross, mvvmlight, and opennetcf.

It's quite an opinionated mvvm framework (with my opinions in it!), it includes data-binding support for Droid and Touch, and it really does encourage code reuse between the platforms.

The source is available from https://github.com/slodge/MvvmCross, it's been used in at least a couple of large projects already and it's still under active development.

There's an introductory presentation on it on slideshare: http://www.slideshare.net/cirrious/dev-evening-monotouch-monodroid-mvvm-mvvmcross-and-databinding

One of the more fully featured samples is a conference app:

sql bits app

查看更多
登录 后发表回答