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

Rename MGLAbstractShapeSource #10853

Closed
Closed

Description

@1ec5

MGLAbstractShapeSource is an unfortunate name for an Objective-C class. The word “abstract” recalls Java’s kingdom of nouns. Until iOS SDK v4.0.0 goes out the door, we have an opportunity to rename classes to avoid this mess.

#10410 proposes unifying MGLShapeSource and MGLComputedShapeSource to obviate MGLAbstractShapeSource. That would be the ideal solution, though @asheemmamoowala would have a better idea how feasible it is.

If #10410 doesn’t make v4.0.0, the least we can do is to rename MGLShapeSource to MGLPredefinedShapeSource or somesuch, allowing MGLAbstractShapeSource to take its place as the new MGLShapeSource. This approach would be suboptimal, because the current MGLShapeSource is such a commonly used class that the developer might unknowingly reach for the abstract MGLShapeSource.

/cc @akitchen @lilykaiser

Activity

  1. added
    iOS
    macOS
    on Jan 6, 2018
  2. asheemmamoowala commented on Jan 8, 2018

    @asheemmamoowala
    Contributor

    MGLAbstractShapeSource is an empty class. It doesn't add any interface or shared methods. The header (and corresponding implementation) defines the shared MGLShapeSourceOption and the conversion methods to the corresponding native structs.

    You could get rid of the class and move the options to a new header/impl file.

    That achieves the objectives of this ticket and the first bullet of #10410.

  3. 1ec5 commented on Feb 14, 2018

    @1ec5
    ContributorAuthor

    You could get rid of the class and move the options to a new header/impl file.

    That sounds reasonable. It opens a small can of worms, though:

    • Remove MGLAbstractShapeSource.
    • Make MGLComputedShapeSource inherit directly from MGLSource. If MGLComputedShapeSource doesn’t inherit from MGLShapeSource, we need to get “shape” out of the name to avoid confusion. On the other hand, we may eventually need to make a distinction between computed sources that produce vector tiles versus those that produce raster tiles: Programmatically generated raster sources #7471.
      • Rename MGLComputedShapeSource to MGLComputedVectorSource? That would be confusing because it doesn’t inherit from MGLVectorSource.
      • Rename MGLRasterSource and MGLVectorSource to MGLRasterTileSource and MGLVectorTileSource, respectively? Then we could have both MGLVectorComputedSource alongside MGLVectorTileSource, with the possibility of an MGLRasterComputedSource in the future.
    • Move MGLShapeSourceOptionWrapsCoordinates and MGLShapeSourceOptionClipsCoordinates to MGLComputedShapeSource.h – but keep it the same MGLShapeSourceOption type? Would that be confusing? Would it also be confusing that MGLComputedVectorSource accepts MGLShapeSourceOptions but MGLVectorSource does not?
      • Rename MGLShapeSourceOption to MGLShapeProvidingOption, in reference to a theoretical MGLShapeProviding protocol that we don’t have to define just yet.

    /cc @mapbox/maps-ios

  4. jfirebaugh commented on Feb 21, 2018

    @jfirebaugh
    Contributor
    • MGLSource
      • MGLTiledSource
        • MGLTiledRasterSource
        • MGLTiledVectorSource
      • MGLComputedVectorSource
      • MGLShape[Vector]Source
      • MGLImage[Raster]Source

    (Unclear to me whether it's worth renaming the latter two.)

    • * `MGSourceOptionMinimumZoomLevel`
      * `MGSourceOptionMaximumZoomLevel`
      * `MGLTiledSourceOptionTileCoordinateSystem`
      * `MGShape[Vector]SourceOptionClustered`
      * `MGShape[Vector]SourceOptionClusterRadius`
      * `MGLComputedVectorSourceOptionWrapsCoordinates`
      * `MGLComputedVectorSourceOptionClipsCoordinates`
      
  5. 1ec5 commented on Feb 21, 2018

    @1ec5
    ContributorAuthor

    it makes the hierarchy resistant to extension by a new source type that doesn't want to accept an option that all sources have heretofore accepted

    We could combine MGLShapeSourceOption and MGLTileSourceOption into a single MGLSourceOption extensible enumeration and have each source class’s initializer accept a dictionary with MGLSourceOptions as keys, ignoring the ones it doesn’t support. There’s plenty of precedent for that in Cocoa Touch, particularly in NSNotification userInfo dictionaries. The downside is that there’s less compile-time checking to prevent the use of options that get ignored, but documentation can mitigate that issue to some extent.

    Note that, with #11224, MGLRasterDEMSource will accept one option that MGLRasterSource, its concrete superclass, does not.

  6. self-assigned this
    on Mar 30, 2018
  7. added
    beta blocker
    on Mar 30, 2018
  8. 1ec5 commented on Apr 2, 2018

    @1ec5
    ContributorAuthor

    Fixed in #11568 on the release-boba branch, which will become iOS map SDK v4.0.0 and macOS map SDK v0.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

beta blockeriOSmacOSrefactorruntime styling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions