-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate "Methods" and "Extension Methods" sections #3941
Comments
Thanks for the suggestion. Methods and extension methods are currently integrated, intentionally, to avoid the converse problem: If you were looking for a method available on a class (you don't know that it's an extension method, and why should you?), it would become difficult to find the method. Why should they be separated? Why would a user be looking for |
I don't think we should treat methods and extension methods like they're exactly the same. Unlike methods, extension methods might not be available depending on your
Is that true? We already separate static methods, but I wouldn't say they're more difficult to find.
In my opinion, the separate sections would organize the content better :) |
Yes, I think so. If I am looking to call a method on an instance of a class, I look in the Methods section. Sometimes I'm thrown because it turns out I'm looking for a property (like I don't see static methods as related to instance methods at all; it kind of grates on me that we call them "methods" when they don't use an instance of the enclosing class as a receiver.
I think it would be a disservice to "set aside" methods that might require an additional import. I can't think of a reason a user would be prefer to not use the method they we seeking, if it would require importing an additional library. |
I think this is the core of our disagreement. I personally like that properties and operators are separated, I find this makes the docs more organized. In my mind, these aren't "set aside" -- they're grouped together!
What would you call them instead? Personally, I'm ok with that name as it's a widely understood term that is easily understandable by newbies. Side note: dart doc also separates classes and exceptions. |
Static functions. |
It's a hold-over from Smalltalk, where classes are objects and class methods are actual methods whose receiver is the class.
I agree. I doubt that any of our users get confused enough by the term that it's actually worth changing it.
I think that's a valid point. It could also be confusing for users if they look at the current page and see a method on the class, try to use the method in their code, and are then told that the method doesn't exist (because it's an un-imported extension method). Separating extension methods into a separate section is one solution, but as pointed out it might introduce other sources of confusion. I don't claim to have a perfect solution, but one other possibility that comes to mind is to clearly annotate which methods are extension methods and where each extension method comes from (how to import it). A more complex solution would be to have some filtering built in to the output so that a user could ask for subsets such as all methods, only non-extension methods, or maybe only non-inherited methods. |
They are a little bit like "sealed" method, given they are not part of the class definition and cannot be overridden. Implementing that method in a subclass would be like a "new" method (c# keywords in quotes for trying to be clear on what I mean). Sorry if I'm saying a bunch of non-sense... 😅 |
Problem
Currently
dart doc
mixes methods and extension methods in the same "Methods" section (example).If the Flutter framework introduced 50+ extension methods on the
Widget
type, it would flood theWidget
's methods with extension methods. It becomes difficult to findWidget
's "real" methods.Solution
Similar to how the "Static Methods" have a separate section (example), we should consider adding a separate section for "Extension Methods"
The text was updated successfully, but these errors were encountered: