Newsletter Issue #21

Published: 2020-07-07

It’s another quiet week in the world of Compose. But, this week, we take a look at space, ConstraintLayout, and dates/times. Plus, I advise developers to “take a cold shower” and not get too excited too quickly when it comes to Compose.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

TextFields with Hints: A History

As a demonstration of how the world of Compose changes, this question from November 2019 asked how to create a text field with a hint. It attracted four answers, three showing creating one manually, and more recently Gabriele Mariotti pointing out that this is now built in via OutlinedTextField and FilledTextField.

A Space By Any Other Name

The names we use for programming concepts get handed down from past generations, and those names have baggage that make it difficult to work with new concepts. In this week’s highlighted Slack thread, we examine padding, margins, spacing, and how Compose handles these concepts.

Composable Commentary

Posts, videos, and other new information related to Jetpack Compose!

Exploring Constraint Layout in JetPack Compose

Siva Ganesh Kantamani is back, this time with an overview of using the Compose implementation of ConstraintLayout and how its DSL compares to how we would create ConstraintLayout in traditional layout XML.

Resource Roundup

100% pure code!

GitHub: vanpra / ComposeDateTimePicker

Pranav Maganti has a date, time, and date-and-time picker dialogs implemented as composables, using Java 8 date/time types.

GitHub: vanpra / ComposeViewPager

Pranav Maganti also has a ViewPager implementation in Compose, powered by a HorizontalScroller wrapped around a Stack.

…And One More Thing

Jetpack Compose is going to be awesome!

But, let’s not go crazy, either.

Another recent Stack Overflow question highlights some aspects of the “irrational exuberance” that I see in some corners of Compose fandom.

Can you ship a production app using the Compose developer preview? Yes.

Is that a good idea? Right now, probably not, unless being “first to market” with something specifically implemented in Compose is important. Bear in mind that the user will be oblivious to your choice of UI toolkit, on the whole. Ideally, users will not care whether you use Compose or the classic View system. And, in the short term, the likely reason that they will care is if they run into a Compose bug. Developer previews are meant for experiments, not for production. So, while nothing stops you from shipping an app with Compose, that may not be in your best interests, until Compose becomes far closer to being stable.

Could somebody new to Android learn Compose and skip things like fragments and the classic View system? Theoretically, yes.

Is that a good idea? Right now, probably not. The amount of stuff written about Compose is very limited compared to the decade-plus of knowledge out there about views. Using Compose is a bit challenging for experienced developers. I cannot recommend newcomers to Android start with it today. In a couple of years, I expect that to change.

I get the enthusiasm over Compose. But at the same time, do not let the “sex appeal” of Compose blind you to the risks and costs of using such a new technology right this moment, for cases where Compose is not necessary.