📜 ⬆️ ⬇️

Behind the scenes of MixRadio: from the start of development to the Nokia X platform

Friday, Habr!
As you already know at the Barcelona MWC 2014 exhibition, we presented a new line of Nokia X smartphones with an entire ecosystem of applications from Microsoft and Nokia.



One of the applications on the Nokia X platform is the well-proven MixRadio music streaming service on Lumia smartphones. And today we want to share with you the story of developers about how they brought this service to the Nokia X platform and other details hidden from the eyes of a simple user.
')
Interesting details for those who are interested in developing applications under the cat.

Creating a common code for MixRadio applications under various platforms has been our main and long-term task throughout the past year. When we first started working on expanding the service, we faced the question of how to allocate efforts as efficiently and effectively as possible. We came up with an action plan based on the architecture created as a result of working on the MixRadio application for Windows 8. We presented this architecture at the Build 2013 conference .

Why was the common code needed?


So why are we so committed to ensuring that all our applications use the same code? First of all, because MixRadio should have identical functionality and usability on all devices, namely on devices of the Lumia line, Asha smartphones, computers and tablets on Windows 8.1, the web version of Mixrad.io, and now also on Nokia gadgets X.

The Nokia MixRadio service itself is a kind of your personal radio station, which can be accessed from any device. This means that by creating a MixRadio application for a new platform, we endow it with the basic functionality that is present in previously created applications for other platforms. It is this application basis that can be implemented thanks to the common code.

Common code can be used, for example, to access the API backend to retrieve data from a server, to manage an account or to cache data, and so on.

Every time we created a new application and understood that the application has the potential to develop a common code, we had to face a choice. Which is more correct: learn the lessons of past developments and create the “right” new code from scratch or try to reuse the code that we already have and continue to make gradual improvements by careful refactoring?



Trying different approaches, we made some important discoveries for ourselves. The new code, which was not fully integrated into existing applications from the very beginning, was simply not accepted by them. In contrast, code reuse, thanks to a good planning process, was relatively simple when creating new applications. Even in spite of the fact that we missed the opportunity to create a new, more advanced code.

Another advantage of code reuse is its continuous improvement as a result of many iterations. Such a code contains perhaps not always noticeable, but important changes that correct the errors that have been identified throughout its existence. This is a good basis for creating something new, which will allow you to significantly gain time, unlike the situation when you are writing an application from scratch.

Using shared code also simplifies the process of subsequent application support. Want to change the work of a particular function of the application? Instead of involving several separate teams of developers, it would be easier to change the code in one place. All applications based on common code will receive updates simultaneously. The same applies to the correction of errors.

In general, we believe that there is enough reason to use a carefully thought out common code. That is why we use a common architecture when creating applications for MixRadio.

The overall architecture of MixRadio



Existing MixRadio Architecture


Target MixRadio Architecture

The target application architecture of MixRadio is based on the MVVM design pattern . It was chosen by us because it allows us to use as much common code as possible between all our applications. MVVM facilitates the separation of user interface (UI) from business logic. This means that we can adapt to different platforms while keeping the application foundation the same for all applications.

Each MixRadio application contains a minimum amount of unique code, mainly responsible for the visual component or helping the application to function successfully in a particular platform (ie, responsible for the specific platform). The rest of the code, containing business logic, view models and other models, is common and is used by all applications.

Portable Class Libraries (PCLS) let you share key business logic across multiple platforms. That is why all our common code is created in PCLS.

Development history


Windows phone

The starting point in the history of MixRadio can be called the development of the Nokia Music application for Windows Phone 7. However, at first we did not think about any common code - it appeared only when we created the Nokia Music application on Windows Phone 8. We used some common ideas ( views) and view models (ViewModels) using basic related files in Visual Studio.

Windows 8

When we started developing an application for Windows 8, the overall architecture has already been defined. As a first step towards a common architecture, a single software layer was created. Even then, it was distinguished by the many advantages of a common architecture.

The shared layer was a portable class library that simultaneously supports the Windows Phone 7/8 and Windows 8 platforms.

In addition, when creating an application for Windows 8, we integrated into all applications the MixRadio API toolkit, which is still freely available to all developers.

Nokia X

The advent of the Nokia X family of smartphones has allowed us to take a step forward and go beyond the Windows platform. And with this, Xamarin www.xamarin.com , a framework for cross-platform development of mobile applications using C #, helped us. Read more about it in this post .

Xamarin provides fantastic support for the runtime and related .NET tools on alternative (non-Microsoft) platforms. This means that our development teams can create new applications for new platforms using our familiar development tools and common code that is already involved in other applications. In addition, thanks to a recently announced partnership with Microsoft, Xamarin has added support for PCLS to its framework. This allowed us to achieve even more convenient work with our target architecture and shared libraries.

After a little research, we chose MvvmCross as the main framework for MVVM. MvvmCross was for us the final piece of the puzzle when transferring MixRadio to a new platform. He helped to abstract from the specifics of the platform, thereby solving one of the main problems in cross-platform development. MvvmCross allowed to fully implement the functionality of MixRadio in the application for Nokia X, while retaining all the advantages of the new platform.

Next steps


The final step on our path to a common architecture will be the replacement of legacy code in applications for Windows Phone and Windows 8 by removing it from existing shared PCL libraries and integrating with the common code base. After the release of the application for Nokia X, this is our next main task and we have already begun work.

API


For developers who plan to use Xamarin to create applications for the Nokia X platform, we are reporting good news - you can use our C # SDK toolkit or the REST API interface to integrate MixRadio into your applications.

Source: https://habr.com/ru/post/215031/


All Articles