· 6 min read Posted by Kevin Galligan
Scaling: Why it's hard
KMP For Native Mobile Teams
This is a post series with several sections. If you landed here first, make sure to go back to the Intro to get the full story.
Overview
There is much to consider for the scaling phase. We’ve found that most teams who start with KMP, and stick with it long enough to include real code within their apps, will continue using KMP. Measuring success is more about:
- How much of the code is actually shared?
- How much more efficient is development with KMP?
- How “happy” is the team, both with the process and the outcome?
- How much time and effort were required to get there?
As stated at the beginning, KMP’s potential is huge, but any team’s particular outcome depends heavily on approach. Let’s start with a review of what “scaling” actually means.
Scaling and Feature Dev
Scaling KMP means implementing features with KMP because that is the bulk of the work for app development. Using KMP to publish a few modules with significantly less code and code that changes less frequently means you’re not using KMP that much.
Obviously, if KMP can only be used for a subset of code, its impact on your development is severally limited.
In short, KMP needs to be used where the bulk of your work is being done.
Teams often have difficultly with scaling. The difficultly emerges from a few areas. Most prominent:
- Workflow model. Library publishing models don’t support feature dev. Having a single repo with the KMP and native apps’ code solves library publishing issues, but can introduce its own.
- Team member roles and “lanes”. This is essentially who is editing what, and what is the process that a new team member takes to “get there”.
- Clear “borders” and architectural patterns. Where does the shared code “stop”, and what patterns does your team adopt for that architecture?
Tooling choice, configuration issues, and other similar topics, while important, are more mechanical. They generally have clear solutions. Team structure, app-specific decisions, and day-to-day workflow are less clear-cut and critical to resolve.
Workflow Model
Much of the trouble with scaling is with the workflow model. In our work with teams, we’ve observed some basic core issues with structure and planning.
Library publishing doesn’t scale
Teams almost universally introduce KMP by publishing “libraries”. That is what we recommend in the Piloting and Iterating phases. In review, publishing libraries is what it sounds like. Code is developed independently, and “published” with sequential versions. In our formal terminology, it is “unidirectional”.
The first major issue is that scaled development requires frequent, often conflicting changes.
The second is the disconnect between portions of code that should be edited as a single unit. Editing UI separately from the architecture that supports it is difficult and inefficient. Also quite frustrating for the team. They won’t like it.
Feature development, or scaling in general, with library publishing is the wrong configuration. The structures are simply incompatible.
Monorepos deeply couple the apps and teams
To address the library publishing problem, most KMP devs and teams assume the next step is merging all of the app and KMP code into a single repo, editing everything in place.
This is the default configuration for KMP, at least as far as all samples and default tooling are concerned. It is such an ingrained assumption that few really question it. Myself included, until we spent significant time working with teams doing it.
It is the default model, and it’s wrong.
Not “technically” wrong. It’s simply not how native mobile teams work.
The root cause is that KMP code edits impact both platforms at the same time. The effect is that both apps and teams are tightly coupled.
Team member roles
Keeping our “native mobile teams” context in mind, a lack of role definition often creates issues. Unless the plan for your team is to completely ignore platform specialties, from day 1, some form of task alignment to skill set needs to be implemented.
Even if fully “merging teams”, it’s important to remember that no matter how long your team has been operating in that mode, every new team member is at “day 1” all over again.
“Onboarding” is obviously not unique to KMP, but the added platform dimensions, and relative lack of experience at present (KMP is new), exacerbate it.
Clear “borders” and patterns
Most platform teams develop general guidance around architectural patterns used in their codebase. An “anything goes” approach is chaotic.
That, of course, is within a context where the developers have a general familiarity the platform’s conventions and patterns.
In a KMP context, engineers will be significantly less familiar with each other’s platform. Clear agreement and documentation on the patterns is more valuable than it would be in a purely native-dev environment.
Of particular importance is the “border”. Android and iOS have different lifecycles and conventions. With the addition of Compose and SwiftUI, both platforms on their own struggle with applying general guidance to specific app situations.
Libraries and patterns in the KMP community are virtually all “Androidy”. The majority of libraries and patterns developed recently will assume Compose as the UI. Applying this general KMP guidance, itself limited and new, can be problematic.
That general KMP guidance, besides causing more technical issues, also makes the sub-par iOS developer experience worse.
Measuring Results
Assessing developer efficiency is notoriously difficult. Speaking as a manager and business owner, I understand the desire. Speaking as a developer, and also as a manager, I understand just how difficult that would be to do.
Implementing any new platform is a risk. Regardless of approach, it will consume people’s time and focus. Being able to confidently say that KMP has been a benefit to your team is necessary. Being able to show that KMP has improved your development efficiency would be great. For some, it is critical. Understanding that your team is enjoying KMP, and that their expertise with the technology is continually improving, would be very valuable as well.
Most measures of efficiency are either verbal reports, or something like “velocity charts”. While neither is particularly accurate on their own, again, KMP is adding a different dimension of complexity.
We’ve talked with teams who have self-reported metrics that are all over the range.
Some Example Discussions
(They’re anonymous, but they’re real)
A team struggling with KMP came for help. It turns out they’ve had amazing success, but were always focused on improving. This was one of the examples of a team that attempted to “merge” the specialists. They’ve been shipping production KMP apps for quite a while, but struggled with the “merged” aspect.
Another team reported that things were going great, and had a very different approach to the tech than we were discussing. I was curious. It turns out “great” meant that they were enjoying learning KMP, but were far from shipping anything. The deadline was, essentially, “when it’s ready”.
Several teams discovered that KMP’s efficiency didn’t scale. The tech was useful, but fell rather short of expectations. Spoiler: they were all using the library publishing model. Each individually had other build and mechanical issues, but the big problem was workflow.
The earlier phases, Piloting and Iterating, are explicitly not focused on performance. Scaling is. Having some useful assessment of progress is important.
Next Section : Scaling: What to do?
While teams struggle to scale, the problems aren’t really complex. They simply need to be identified and addressed.
- 1 - Intro
- 2 - Basic Concepts
- 3 - Getting Started
- 4 - Piloting
- 5 - Iterating
- 6 - Scaling: Why it's hard
- 7 - Scaling: What to do?