Mercari reduces 355K lines of code, a 69% difference, by rebuilding with Jetpack Compose


Mercari reduces 355K lines of code, a 69% difference, by rebuilding with Jetpack Compose

Posted by the Android team

Mercari reduces 355K lines of code, a 69% difference, by rebuilding with Jetpack Compose

In 2020, the Mercari team took on a massive initiative to update its app’s specialized infrastructure. At the time, its codebase was 7 a long time aged and hadn’t gone through any key architectural updates. This affected the team’s skill to create new options and release timely app updates. To take care of this technological financial debt, Mercari released what it referred to as the GroundUP initiative—a full rewrite of its application across platforms, which include Android.

The purpose was to build a completely modernized application with a scalable layout. Although retooling the application, Mercari builders turned to Jetpack Compose, Android’s modern-day declarative toolkit for producing indigenous UI. Through the evaluation, the crew uncovered rewriting in Jetpack Compose would aid clear up their codebase and have more control above how the application seems to be.

A rewrite with much less code

The Mercari team completely rewrote the architecture and tech stack for its Android application employing Jetpack Compose. Mercari builders developed a new structure technique and completely built-in it utilizing Compose, enabling them to very easily take a look at and put into action new features. Using this new style system, the Mercari staff rewrote a lot more than 130 UI screens for its market and modernized the seem and come to feel of numerous of their parts.

With the assist of the Jetpack Libraries, Mercari’s team eradicated all legacy code all through the rewrite, significantly lowering its codebase and producing it far more workable for builders. “Virtually, it’s the same app with way fewer code,” said Allan Conda, Android engineering lead at Mercari. “The rewritten app has about 355,000 much less lines of code, which is about 69% less than what it experienced prior to.”

Moving image showing lines of code that appear and disappear on the leftmost panel of the screen. The spacing between the boxes in the center panel changes, and the overall app view reflects these changes in the rightmost panel.

Interoperability with Views as an early adopter

When the Mercari staff first began its GroundUP initiative, Jetpack Compose was only obtainable in developer preview. They wanted the application published absolutely in Jetpack Compose owing to its new declarative approach to creating UI. Having said that, simply because it was however so new, they discovered by themselves getting to fix for distinctive edge instances making use of both toolkits.

For instance, on Mercari’s listing type screens, end users are prompted to enter specifics about the products they want to listing. People ended up then supposed to be able to pick shots from their unit gallery and rearrange them on this screen working with a drag gesture. Gesture APIs weren’t available in Jetpack Compose at the time, so the workforce took benefit of Compose’s AndroidView to seamlessly integrate Views that dealt with gestures on the listing form display. This furnished a stable yet temporary option to employing drag gestures until the element became out there with Jetpack Compose.

The Mercari crew was impressed by how uncomplicated it was to change in between the two toolkits, and owning the alternative to use Views along with Compose gave them superior handle of edge conditions like this. Compose now supports gesture APIs, and Mercari developers have considering the fact that entirely created and integrated the drag gesture ingredient solely working with Compose.

Jetpack Compose has matured a whole lot considering that Mercari’s preliminary adoption, and most Android builders no for a longer time have to have to fret about having to interoperate with the two toolkits as Android applications can now be prepared wholly in Compose.

Strengthening and monitoring overall performance with Compose

Making use of Compose, the Mercari crew automatic baseline profile technology for each individual stable release of the app and observed it to be really useful. The home screen renders frames up to 2x more quickly with the default Compose baseline profile as opposed to with out a baseline profile. By giving a personalized profile, there is an extra enhancement of up to 20% speedier when Mercari users are scrolling in contrast to just obtaining the default baseline profile.

The group also wrote automatic general performance assessments dependent on the app’s core scenarios with Android Macrobenchmark. “Using Android Macrobenchmark, we can automatically examination commence-up, scroll, and display load periods general performance,” said Allan. “Currently, we have six main eventualities included by these exams, like lookup effects and searching items.”

On top of that, Mercari builders integrated Firebase Effectiveness Monitoring, a actual-time application efficiency monitoring instrument, with tailor made code to work out scrolling efficiency on Compose screens. With Firebase Overall performance Monitoring, the Mercari group detected a general performance challenge on its look for consequence screen. Employing the Android Profiler to pinpoint the trouble, Mercari builders identified there have been bad frame charges when scrolling research outcomes. This resulted in the gradual rendering instances getting lessened by about 23.6%.

The Mercari workforce solved this frame charge problem with guidance from Google’s Compose general performance greatest tactics and Compose balance. Mercari builders experienced the app skip its Composables and hoist the unused states on the search effects screen, appreciably bettering the body costs.

Headshot of Allan Conda, Android Tech Lead at Mercari, similing, with quote text reads 'Jetpack Compose helped us implement our Design System and rewrite 130+ screens and many of our components'

Far more prospects with Jetpack Compose

With fewer code to manage, it is substantially less complicated for Mercari developers to examination and apply options. “We have a ton of experiments we can ultimately conduct working with our refreshed platforms. Our users can count on new functions coming to the Mercari app at a a lot quicker fee,” stated Allan.

Mercari’s developers are energized to additional develop the application applying Animation APIs. With Compose, it’s considerably less complicated to animate parts, which can consequence in large advancements for Android UXs.

Get begun

Enhance your UI progress with Jetpack Compose.

Next Post

Getting Started with WordPress SEO [Best Practices & Plugins]

When it comes to effectively optimizing webpages for search engines, building your site on WordPress gives you an edge. Besides offering a very reliable content management system (CMS), it provides a solid foundation for SEO with a variety of plugins that can help you boost search engine rankings and drive […]
Getting Started with WordPress SEO [Best Practices & Plugins]

You May Like