Architectures
Xamarin applications can be created basically with two major types of architecture: native and layered. I’ll explain better:
Arquiteturas Nativas
They allow you to use the same architecture that would be used if you were making the application using the platform’s native language, by default. It allows you to work exactly as you would in an Objective-C in the iOS or in Java in the 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 only one language on multiple platforms.
Architectures in Layers
They allow your application to have reusable code across platforms. Basically you can have something simple and proprietary where you separate "in hand" a reusable portion of code and all the rest that depends on the platform in different layers. There are more advanced and organized ways to do this with MVC and MVVM.
MVC - Model View Controller
It is the model that is used on the Web and that can be used with Xamarin and C# . This architecture model is made entirely 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 more caring than can be abstracted and with automatic connection (binding
) model with view. It’s the same architecture model that Microsoft uses on 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 abstract several native Apis. Using these libraries with a layered architecture makes you only need to rewrite the view layer for each platform.
I must use separate solutions?
The simplest answer is no. The best is that it is a solution with only all the projects, so that the common projects can be read and loaded at once. This will facilitate your maintenance.
Remember that common libraries should not use platform-specific Apis or features and should preferably be compiled using Portable Class Libraries