What do you think of using a unified entry point for Mondrian APIs? Currently, we have these:
// Classic
mondrianBatchLayout {
backgroundView.mondrian.layout
.edges(.toSuperview)
}
// Structured
view.mondrian.buildSubviews {
ZStackBlock {
button.viewBlock
.size(size)
.padding(padding)
}
}
One big problem we have is that it's very hard to recall which methods to use because the API entry points are all different.
I propose something like:
// Classic
Mondrian.layout {
backgroundView.mondrian.layout
.edges(.toSuperview)
}
// Structured
Mondrian.buildSubviews(view) {
ZStackBlock {
button.mondrian.build
.size(size)
.padding(padding)
}
}
The names I used (Mondrian.layout, mondrian.layout, .mondrian.build) are all placeholders. The naming can be decided later, but my proposal is based on three principles:
- The global entry point (
Mondrian.* in the example above) would become the same entry point for both classic and structured layout syntaxes.
- We will define two terms we would use to separate the classic and structured layout contexts. In the example above, I used
Layout for classic layout (Mondrian.layout(), backgroundView.mondrian.layout)
Build for structured layout (Mondrian.buildSubviews(), button.mondrian.build)
- The subview namespace is easily remembered from the enclosing context. So inside
Mondrian.layout(), views would use .mondrian.layout and inside Mondrian.buildSubviews()views would use .mondrian.build. They don't have to be the same, but the pair should be very memorable. For example: Mondrian.build*() with inner view.mondrianBlock (building blocks)
This is a breaking change from the current syntax, but I think the biggest annoyance with the API right now is the bad discoverability of the methods. If you think the guidelines above are good, then we can comment on this Github issue on naming ideas.
What do you think of using a unified entry point for Mondrian APIs? Currently, we have these:
One big problem we have is that it's very hard to recall which methods to use because the API entry points are all different.
I propose something like:
The names I used (
Mondrian.layout,mondrian.layout,.mondrian.build) are all placeholders. The naming can be decided later, but my proposal is based on three principles:Mondrian.*in the example above) would become the same entry point for both classic and structured layout syntaxes.Layoutfor classic layout (Mondrian.layout(),backgroundView.mondrian.layout)Buildfor structured layout (Mondrian.buildSubviews(),button.mondrian.build)Mondrian.layout(), views would use.mondrian.layoutand insideMondrian.buildSubviews()views would use.mondrian.build. They don't have to be the same, but the pair should be very memorable. For example:Mondrian.build*()with innerview.mondrianBlock(building blocks)This is a breaking change from the current syntax, but I think the biggest annoyance with the API right now is the bad discoverability of the methods. If you think the guidelines above are good, then we can comment on this Github issue on naming ideas.