App Mobile Multiplatform with Xamarin



This question is more architecture-oriented. I recently started learning Xamarin to develop Apps Mobile, Xamarin, which until then has proven to be very flexible, has bindings for native Android and iPhone APIs.

Question (s)

  • How do you give an Xamarin application architecture with a focus on reusing code between platforms?
  • Which parts of the App should be developed for general purpose and which should be developed for a particular platform?
  • Should I keep different Solutions ( solutions ) different for each project on each platform?
  • Additional Information

    Any information that may be relevant to the question can be attached to the response, as well as some possible source of data about the subject.

    asked by anonymous 24.01.2014 / 19:11

    1 answer



    Xamarin applications can basically be built with two major architecture types: native and layered . I'll explain better:

    Native Architectures

    They allow you to use the same architecture that would be used if you were making the application using the native language of the platform, by default. It allows you to work exactly as you would in an Objective-C application on iOS or Java on Android .

    The advantage of using this architecture is that it is easy to migrate to Xamarin in this way. If you already know the platform in question just do the same thing using C # instead of the native language. The downside is that you will have an application stuck on the platform and will not make use of the advantages of being able to use just one language on multiple platforms.

    Layered Architectures

    They allow your application to have cross-platform reusable code. Basically you can have something simple and owner in which you separate "in hand" a reusable portion of code and everything else that depends on the platform in different layers. There are more advanced and organized ways of doing this with MVC and MVVM .

    MVC - Model View Controller

    It is the template that is used on the Web and can be used with Xamarin and C #. This architectural model is entirely made by the developer with the help of libraries such as MonoCross .

    MVVM - Model View View-Model

    It is a specialization of MVC with a layer that takes care of what can be abstracted and with the automatic connection ( binding ) of the model with the view. It is the same architecture model that Microsoft uses in WPF - Windows Presentation Foundation . This architecture model is made entirely by the developer with the help of libraries such as MvvmCross .

    How to choose what to put on each layer

    There are some libraries of Xamarin itself that abstracts from various native APIs. Using these libraries with a layered architecture means you only need to rewrite the view layer for each platform.

    Should I use separate solutions?

    The simplest answer is no. It is best that it be a solution with all projects only, so that common projects can be read and uploaded at once. This will make it easier to maintain.

    Remember that common libraries should not use platform-specific APIs or features and should instead be compiled using Portable Class Libraries

    25.01.2014 / 03:58