It’s well known, computer science is a world in constant evolution, new technologies are presented every day to simplify apps development and software for us developers.
One of these technologies is Jetpack Compose, already in the stable release version.
Jetpack Compose is a completely new framework that completely overturns the creation of Android Apps by exploiting the potential of Kotlin and what declarative programming can offer: dynamism, ease of reading, optimized code and much less superstructure generated by evolutions of the framework that has now become „Legacy“ all that we know and what we have always developed with.
Written entirely from the ground up, Compose offers the potential for a true change of gear in development. To date, you already have the ability to create apps using most of the widgets present in the Material Design. To accompany it all, Chris Banes created the Accompanist library which collects widgets and integrations that further simplify development.
The most important concept in Compose is based on the State: an object that represents what the UI must show at a certain moment of its execution. State updated, UI updated. All this in real time. Stunning huh? 🔮
Thanks to the full integration with the Coroutines, the screens and widgets written using Compose are able to subscribe to StateFlow (or SharedFlow) in order to receive every update emitted and direct it to the UI which, consequently, will update itself showing the data correctly updated or will perform actions specifications.
However, does it really make sense move to Compose for green fields projects or even migrating (even partially) apps already in production or in early development stage?
Let’s start with the migration of an app.
As is known, keeping an app updated is a job that pays off over time; Ease of assimilation of Breaking Changes, Bugfixes of the libraries themselves and greater stability of the latter. The more the libraries are updated the less chance that some app features based on these libraries will be deprecated.
The question remains: Is rewriting an entire app just to introduce Compose worth it? I honestly can’t give a clear and definite answer. Mobile apps undergo many refactor cycles during their „life“ where some or many portions of code are rewritten and optimized… in these cases you could think of a gradual introduction of Compose, as it is fully interoperable with the old framework, even if it remains an operation of lower priority than the real maintenance of an app that perhaps has thousands of lines of code.
Instead creating a new app?
In this regard, I can say that it makes absolutely sense to invest in this new technology as it is expected to become a standard in a short time but not only…
In the last period I got to work on a new project: a whitelabel for an eCommerce app with the possibility of customization for various brands.
We decided to take a new approach, new app, new technology. So we started with a deep study of Compose through the Google documentation and a very complete Pathway always made available by Big G.
The project started when Jetpack Compose was in alpha and slowly between a breaking change and a few bugs we managed to bring the first version of the app for the first brand into production.
I cannot hide from you that it has been a path full of pitfalls: the framework knowledge process, the inexplicable behaviours caused by some bugs due to the maturity of Compose and the absorption of breaking changes have created moments of panic that have helped us to learn more about the technology and to release a quality and very solid app, thanks also to the continuous support from the Google development team that has solved many bugs during the various releases and to the community that promptly opens the reports.
In conclusion: I must admit that I was positively surprised by this new framework; the simplicity with which it is possible to create widgets and reusable components in different contexts of the app, the full integration with Kotlin and the Coroutine and the simplicity and fun during its use are its strengths.
I am sure that over time it will only improve and become more and more complete.
P.S. Rest assured, it does not end here… stay tuned, the next article is around the corner 😎