Behind the Scenes of MixRadio: From the Beginning of Development to the Nokia X Platform

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



    One of the galaxy of applications on the Nokia X platform is the MixRadio music streaming service that has proven itself on Lumia smartphones. And today we want to share with you a 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 cut.

    Creating common code for MixRadio applications for various platforms has been our main and long-term goal throughout the past year. When we were just starting to work on expanding the service, we were faced with the question of how to rationally and efficiently distribute efforts. We came up with an action plan based on the architecture created as a result of work on the MixRadio application for Windows 8. We presented this architecture at the Build 2013 conference .

    Why was a generic code needed?


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

    Nokia MixRadio service itself is a kind of your personal radio station, access to which can be obtained from any device. This means that when creating the 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 basis of the application that can be implemented thanks to a 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.

    Each time we created a new application and realized that the application has the potential to develop common code, we had to get up to the choice. What is more correct: to draw lessons from past developments and create a “correct” new code from scratch, or try to reuse the code that we already have and continue to make gradual improvements through 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, due to the quality planning process, was relatively simple when creating new applications. Even though we missed the opportunity to create new, more advanced code.

    Another advantage of code reuse is its continuous improvement as a result of many iterations. Such code contains possibly not always noticeable, but important changes that correct those errors that were 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 write an application from scratch.

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

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

    General MixRadio Architecture



    Existing MixRadio Architecture MixRadio


    Target Architecture The MixRadio

    Target Application Architecture is based on the MVVM design pattern . It was chosen by us, because it allows you to use as much common code as it is generally 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 framework unified 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 specific platform (i.e., responsible for the specifics of the platform). The rest of the code, containing business logic, presentation models, and other models, is common and is used by all applications.

    Portable Class Libraries (PCLS) allow you to share key business logic across 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 general ideas ( views) and view models (ViewModels) using the main linked files in Visual Studio.

    Windows 8

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

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

    In addition, when creating the application for Windows 8, we integrated the MixRadio API tools into all applications , which to this day are freely available for all developers.

    Nokia x

    The advent of the Nokia X family of smartphones has allowed us to take a step forward and go beyond Windows platforms. And Xamarin www.xamarin.com , a framework for cross-platform development of mobile applications using the C # language, helped us in this . You can 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 the usual development tools and common code that is already used in other applications. In addition, thanks to a recently announced partnership with Microsoft, Xamarin has added PCLS support 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 MvvmCrossas the main framework for MVVM. MvvmCross became the final piece of the puzzle for us when porting MixRadio to the 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 MixRadio functionality in the application for Nokia X, while preserving all the advantages of the new platform.

    Next steps


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

    API


    For developers planning to use Xamarin to create applications for the Nokia X platform, the good news is that you can use our C # SDK toolkit or REST API to integrate MixRadio into your applications.


    Also popular now: