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.

Documentation for abstract classes makes initialization unclear #8635

Closed

Description

@1ec5

The documentation for abstract classes and their concrete subclasses make it very difficult for inexperienced developers to figure out how to initialize the concrete subclasses. We basically give the developer a bureaucratic runaround between the concrete and abstract class documentation.

For example, the documentation for MGLVectorSource links to its superclass, MGLTileSource, and provides an example of using -[MGLVectorSource initWithIdentifier:tileURLTemplates:options:] in Swift. However, the link to MGLTileSource documentation is minimal, in a style that the developer is likely to miss (even after realm/jazzy#713), and the Swift example is of little use to Objective-C developers. Moreover, even if the developer follows the link to MGLTileSource, that document says, “Do not create instances of this class directly … Instead, create instances of MGLRasterSource and MGLVectorSource.” An inexperienced developer is likely to misinterpret this warning to mean that they shouldn’t use any of the MGLTileSource methods at all.

We should continue to document abstract initializers where they’re declared, to reduce duplication. However, we should make it crystal clear how to initialize each of the concrete subclasses. For example:

To create an MGLVectorSource in Objective-C, use the -[MGLTileSource initWithIdentifier:tileURLTemplates:options:] method on a newly-allocated MGLVectorSource object. In Swift, use the MGLVectorSource(identifier:tileURLTemplates:options:) initializer, seen in the example below.

jazzy will automatically link the reference to -[MGLTileSource initWithIdentifier:tileURLTemplates:options:], whereas it’ll leave the Swift syntax unlinked. I think this is OK.

/cc @jfirebaugh @jmkiley @friedbunny

Activity

  1. added
    iOS
    macOS
    on Apr 4, 2017
  2. added this to the ios-v3.6.0 milestone on Apr 4, 2017
  3. self-assigned this
    on Apr 14, 2017
  4. jmkiley commented on Apr 17, 2017

    @jmkiley
    Contributor

    I agree that we should make it more positive and focused on what to do (as opposed to what not to do). This will make it more clear and concise. For example, this may be better:

    Create instances of MGLRasterStyleLayer and the concrete subclasses of MGLVectorStyleLayer in order to use MGLForegroundStyleLayer's methods.

    or

    Create instances of MGLRasterStyleLayer and the concrete subclasses of MGLVectorStyleLayer rather than direct instances of MGLForegroundStyleLayer.

    We would need to make sure users are directed to subclasses of relevant sources/layers from the beginning.

    Edited for wording :)

  5. 1ec5 commented on Apr 17, 2017

    @1ec5
    ContributorAuthor

    It’s worth noting that @jfirebaugh has moved most of the abstract classes’ initializers to their concrete subclasses in #8626.

  6. 1ec5 commented on May 23, 2017

    @1ec5
    ContributorAuthor

    What are the next steps following #8626? Do we still need to make this change for iOS SDK v3.6.0?

  7. jmkiley commented on May 23, 2017

    @jmkiley
    Contributor

    We should still make the documentation for these classes emphasize what to do (or how to use the properties from that class #8635 (comment)), rather than what not to do. I can do that today.

  8. jmkiley commented on Jun 14, 2017

    @jmkiley
    Contributor

    Addressed in #9095

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

Metadata

Metadata

Assignees

Labels

documentationiOSmacOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions