Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Style attribute enumerations redundantly include layer class names #6577

Closed

Description

@1ec5

The style layer classes’ paint attributes are named somewhat redundantly, for instance -[MGLCircleStyleLayer circleOpacity]. Since there’s no possibility that, say, lineOpacity would ever exist on the same class, we should remove the first word from this property and any property like it. It’s totally fine if, say, width means something slightly different on circle and line style layers, since the meaning on each is consistent with developer expectations.

Putting on the v3.4.0 milestone because we won’t be able to change this later without breaking backwards compatibility.

/cc @frederoni @incanus

Activity

  1. added
    iOS
    macOS
    on Oct 4, 2016
  2. added this to the ios-v3.4.0 milestone on Oct 4, 2016
  3. 1ec5 commented on Oct 4, 2016

    @1ec5
    ContributorAuthor

    This would also simplify enum names. For example, MGLLineStyleLayerLineTranslateAnchorMap would become MGLLineStyleLayerTranslateAnchorMap. We could go a little further, shortening it to MGLLineTranslateAnchorMap.

  4. incanus commented on Oct 4, 2016

    @incanus
    Contributor

    Since there’s no possibility that, say, lineOpacity would ever exist on the same class

    Is this true? For fills, we've long talked about allowing for variable-width outline (mapbox/mapbox-gl-style-spec#223, #1737) and I could see possibly getting a circle outline someday.

  5. 1ec5 commented on Oct 4, 2016

    @1ec5
    ContributorAuthor

    If so, I think the style specification would call the property something else, like line-stroke-opacity, so there would be no collision. As it is, the only properties that aren’t prefixed pro forma with the layer type are the layout properties that are shared among the types.

  6. 1ec5 commented on Oct 4, 2016

    @1ec5
    ContributorAuthor

    @lucaswoj points out that many symbol properties aren’t prefixed with symbol- but are instead prefixed with text- or icon-. Could we use a heuristic like:

    • If the first part of the property name matches the layer type, omit it.
    • Otherwise, use the property name verbatim.

    That would allow us to differentiate where needed but avoid redundancy in most of the API. However, it would assume that the circle layer type can’t have a line-color property; it’d have to be called circle-line-color instead. I think that’s a reasonable constraint to put on the style specification.

    Even if we can’t shorten the property names, I still think it’d be desirable to shorten the unwieldy enum values.

  7. jfirebaugh commented on Oct 4, 2016

    @jfirebaugh
    Contributor

    I suggest you just accept the redundancy in property names. That's the most predictable and future-proof solution.

    Shortening the enum values seems fine. Those aren't prefixed in the style spec to begin with.

  8. changed the title [-]Style attribute names redundantly include layer type[/-] [+]Style attribute enumerations redundantly include layer class names[/+] on Oct 4, 2016
  9. 1ec5 commented on Oct 4, 2016

    @1ec5
    ContributorAuthor

    Alright, not the end of the world. Retitled to reflect the focus on enumeration names and values instead.

  10. self-assigned this
    on Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

iOSmacOSrefactorruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions