apk.fm / News / Android Developers Blog: Mindful architecture: Headspace’s refactor to scale

Android Developers Blog: Mindful architecture: Headspace’s refactor to scale


Posted by Manuel Vicente Vivo, Android Developer Relations Engineer

Contributors: Mauricio Vergara, Product Advertising and marketing Supervisor, Developer Advertising and marketing, Marialaura Garcia, Affiliate Product Advertising and marketing Supervisor, Developer Advertising and marketing

Headspace Technical case study graphic

Govt Abstract

Headspace was able to launch new wellness and health options, however their app structure wasn’t. They spent eight months refactoring to a Mannequin-View-ViewModel structure, rewriting in Kotlin and bettering take a look at protection from 15 to 80%. The improved app expertise elevated MAU by 15% and elevated overview scores from 3.5 to 4.7 between Q2 and This autumn of 2020. To study extra about how Headspace’s deal with Android Excellence impacted their enterprise, learn the accompanying case research right here.


Headspace has grown into a pacesetter in mindfulness by creating an app which helps thousands and thousands of individuals to meditate every day. Mindfulness goes far past meditation, it connects to all features of an individual’s life. That concept prompted the newest stage in Headspace’s evolution. In 2019, they determined to increase past meditation and add new health and wellness options to their Android app. Headspace realized that they would wish a cross-functional staff of engineers and designers to have the ability to ship on the brand new product imaginative and prescient and create a superb app expertise for customers. An thrilling new part for the corporate: their design staff began the method by creating prototypes for the brand new expertise, with contemporary new designs.

With designs in hand, the one factor stopping Headspace from increasing their app and broadening customers’ horizons was their present Android software program structure. It wasn’t properly structured to help all these new options. Headspace’s improvement staff made the case to their management that constructing on the present code would take longer than a whole rewrite. After sharing the imaginative and prescient and getting everybody on board, the staff set out on a collective journey to write down a brand new Android app in pursuit of app excellence.

The Android Rewrite

Headspace’s Android improvement staff first wanted a handy technique to standardize how they constructed and carried out options. “Earlier than we wrote a single line of code, our staff spent every week evaluating some necessary implementation selections for the inspiration of our app,” Aram Sheroyan, an Android developer at Headspace explains;

“This was essential pre-work in order that we had been all on the identical web page after we truly began to construct.”

Immersing themselves in Google’s literature on the newest, greatest practices for Android improvement and app structure, the staff discovered an answer they may all confidently agree on. Google really helpful refactoring their app utilizing a brand new base structure: model-view-view-model. MVVM is a widely-supported software program sample that’s progressively turning into business customary as a result of it permits builders to create a transparent separation of considerations, serving to streamline an app’s structure. “It allowed us to properly separate our view logic,” Sheroyan defined.

With MVVM as the bottom structure, they recognized Android’s Jetpack libraries, together with Dagger and Hilt for dependency injection. The brand new instruments made boilerplate code smaller and simpler to construction, to not point out extra predictable and environment friendly. Mixed with MVVM, the libraries supplied them with a extra detailed understanding of how new options must be carried out. The staff was additionally in a position to enhance high quality in passing arguments between features. The app had beforehand suffered from crashes on account of NullPointerException errors and incorrect arguments. Adopting the safeArgs library helped to eradicate errors when passing arguments.

In rewriting the app, the staff additional made positive to comply with the Repository sample to help a clearer separation of considerations. For instance, as a substitute of getting one enormous class that saves information in shared preferences, they determined that every repository’s native information source ought to deal with the respective logic. This separation of knowledge sources permits the staff to check and reproduce enterprise code exterior of the dwell app for unit testing with out having to alter manufacturing code. Separating considerations on this means made the app extra steady and the code extra modular.

The staff additionally took the chance to completely translate their app into the Kotlin programming language, which supplied helpful helper features, sealed courses, and extension features. Eradicating legacy code and changing the combination of Java and Kotlin with pure Kotlin code decreased construct time for the app. The brand new structure additionally made it simpler to write down exams and allowed them to extend take a look at protection from round 15% to greater than 80%. This resulted in sooner deployments, greater high quality code, and fewer crashes.

To seize the brand new consumer expertise within the app’s critiques, Headspace carried out the Google Play In-App Evaluate API. The brand new API allowed them to encourage all customers to share critiques from throughout the app. The implementation elevated overview scores by 24%, and — as retailer itemizing critiques are tied to visibility on Google Play — helped draw consideration to the app’s current enhancements.

Attaining App Excellence

The rewrite took eight months and with it got here a brand new confidence within the code. Now that the codebase had 80%+ unit take a look at protection, they may develop and take a look at new options with confidence reasonably than worries. The brand new structure made this attainable because of its improved logic separation, and a extra reusable code, making it simpler to plan and implement new options.

The construct time for the app decreased dramatically and improvement velocity picked up. The staff’s new readability round greatest practices and structure additionally diminished friction for onboarding new builders, because it was now based mostly on Android business requirements. They may talk extra clearly with potential candidates throughout the interview course of, as they now had a shared architectural language for discussing drawback units and potential options.

With velocity got here sooner implementation of options and an improved retention move. They may now optimize their upsell course of, which led to a 20% improve within the variety of paid Android subscribers relative to different platforms the place the app is revealed. The mixture of a brand new app expertise and the implementation of the brand new In-App Evaluate API led to their overview scores bettering from 3.5 to 4.7 stars between Q2 and This autumn of 2020! Total, the brand new deal with Android App Excellence and the improved scores earned Headspace a 15% improve in MAU globally..

These had been just some of the payoffs from the numerous funding Headspace made in app excellence. Their laser deal with high quality paid off throughout the board, enabling them to proceed to develop their group of customers and lay a stable basis for the longer term evolution of their app expertise.

Get your personal staff on board

If you happen to’re occupied with getting your staff on board to your personal App Excellence journey, try our condensed case research for product house owners and executives linked right here. To study extra about how constant, intuitive app consumer experiences can develop your online business, go to the App Excellence touchdown web page.

Source hyperlink

Take a comment