Examining architectural aspects
In the Component hierarchies section, I showed you that component-based UI frameworks rely on specialization. General features and concepts are implemented in the root component or one of its immediate successors. Such general features include the following:
- Location and size on screen
- Basic visual aspects like background (color)
- Simple user interactions (reacting to clicks)
Any component will provide these features, either in a specialized way or in its basic implementation. Android's view system is class-based, so changing functionality is done by overriding the methods of the parent.
Composable functions, on the other hand, do not have a shared set of properties. By annotating a function with @Composable
, we make certain parts of Jetpack Compose aware of it. But besides not specifying a return type, composables seem to have few things in common. However, this would have been a pretty short-sighted architectural decision...