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
AnalyzerConverter class has no fields, only instance methods #50545
Comments
To the best of my knowledge, objects without state aren't a code smell, they're a valid technique for grouping functions with a similar purpose. I don't see this as a code health issue. Because And given that |
It's certainly cheaper to not instantiate objects. It's also difficult for me to reason about the AnalyzerConverter class. Regardless of the performance benefits, measurable or not, it would be simpler to remove the AnalyzerConverter class and make the static methods top-level. It would be easier to reason about and not invite unnecessary instantiations. It also goes against Effective Dart.
I think it's perfectly valid to improve the code before we decide to support it. The code is used by analysis_server, and it's location in analyzer_plugin is unrelated to whether it should be improved. |
I disagree about priorities, but I'll note that in a recent CL you converted a couple of these methods to being extension methods, which is much more palatable to me than top-level functions (which might have been a misunderstanding on my part; maybe that wasn't what you were thinking). But I still believe that this work should have a much lower priority than you gave it. Whichever way the decision goes I expect this work to be moot in terms of what the final product will contain. |
Ah, I missed that I had given it a priority. OK, downgraded to P3.
I agree. I think it's a method-by-method call, but I do think I'm enjoying the extension methods more than top-level functions. |
For me, that that's because I believe that object-oriented code is much better suited than functional code to the kind of software we're writing. |
AnalyzerConverter class has no fields, only instance methods. It should be refactored to be top-level utility functions and/or extension methods.
As an example of the danger of a class like this, in
_DartNavigationCollector
, which is invoked upon every key press in the editor, we construct a newAnalyzerConverter
, in_addRegionForElement
, for every element in the open file which we might want to navigate to. 😨The text was updated successfully, but these errors were encountered: