You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Documentation for abstract classes makes initialization unclear #8635
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.
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.
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.
Activity
jmkiley commentedon Apr 17, 2017
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:
or
We would need to make sure users are directed to subclasses of relevant sources/layers from the beginning.
Edited for wording :)
1ec5 commentedon Apr 17, 2017
It’s worth noting that @jfirebaugh has moved most of the abstract classes’ initializers to their concrete subclasses in #8626.
1ec5 commentedon May 23, 2017
What are the next steps following #8626? Do we still need to make this change for iOS SDK v3.6.0?
jmkiley commentedon May 23, 2017
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.
[ios, macos] Revised descriptions for abstract classes (#9095)
jmkiley commentedon Jun 14, 2017
Addressed in #9095
Merge release-ios-v3.6.0-android-v5.1.0 (#9416)