
Chapter 2. Sharing Code between Platforms
As we mentioned in the previous chapter, in mobile development there are features that we can share between platforms and features that need to be platform specific.
In this chapter we will explore all the ways we have in Xamarin to share code between platforms.
We will understand and develop a cross-platform pattern called Model-View-View-Model (MVVM) that helps us to separate the business and presentation logic of our application from its user interface. We will use this paradigm in the rest of the book.
Note
The business logic is the part of a program that determines how data can be displayed, stored, created and changed.
The presentation logic is the part of the program that describes how and when business objects are displayed.
MVVM will help us to make our application easier to test, maintain and evolve. It also improves the amount of code we can share between platforms.
It is important to understand that MVVM and separated logics is not the only way to share the code between different platforms. That's the reason why we are going to have a quick overview of the other possibilities we have.