Multiplatform MVVM Framework
essentially provide some guidance / patterns around reusing code in multiple platforms.
AdminJames Montemagno (Admin, Xamarin) commented
I believe with Xamarin.Forms this covers a cross platform MVVM Framework with Shared UI code.
There are other MVVM Frameworks that are compatible with Xamarin as well such as MVVM Light, MVVM Cross, and others.
We have some great docs: http://developer.xamarin.com/search?q=MVVM
Ricky Helgesson commented
The cleanest way to do this is to create a UiMaster and an IUiSlave for each page in the app. The UiMaster is cross platform and has only AttachUiSlave() as public method. The IUiSlave is an interface with the "contract" between the UiMaster and each platform's UiSlave. Then, implement the IUiSlave interface for each platform. On iOS, you would have a MyFirstUiSlaveViewController and on Android, you would have a MyFirstUiSlaveActivity (and alike on each platform). The important stuff here is that the UiMaster is the only thing that communicates with the business logic classes, the database, the REST servers etc. etc. The UiSlave's must ONLY respond to method calls and trigger events specified in the IUiSlave interface for that page. The UiMaster is responsible for making sure that all communication with the UiSlave takes place on the UI thread. The UiMaster is responsible for making sure to call backend stuff on separate threads to not hog the UI thread. The IUiSlave interface for each screen (e.g. IMyFirstUiSlave) has only methods and events. The methods are only called by the UiMaster (on the UI thread). The events are only triggered by the UiSlave implementation class on each platform (on the UI thread). The UiSlaves are 100 % single threaded.
The UiMaster class and IUiSlave interface are part of the "Application Layer" of your application. If you look at the Xamarin documentation and their proposal for how to build stuff, you will see that they claim that the "Application Layer" must be put in the part that is implemented for each platform. But, by building this way, you can actually have the Application Layer in the Cross Platform Realm!!! Only the UiSlave implementation classes are platform specific - and usually they are very simple to write - just make sure to add values to a list or trigger an event OnTouchUpInside etc.
The pattern is almost exactly the strict version of Model-View-Presenter.
This way of building things makes the code extremely clean. We have a framework setup on those principles. Please contact me if you are interested in some form of cooperation (firstname.lastname@example.org).
Albert Santantoni commented