Skip to content
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

Reorder constructors and fields in code example on Constructors page #5462

Closed
1 task done
Turskyi opened this issue Jan 13, 2024 · 3 comments
Closed
1 task done

Reorder constructors and fields in code example on Constructors page #5462

Turskyi opened this issue Jan 13, 2024 · 3 comments
Assignees
Labels
a.language Relates to the Dart language tour cl.wont-fix Issue closed as it either can't be or won't be fixed e1-hours Can complete in < 8 hours of normal, not dedicated, work from.page-issue Reported in a reader-filed concern p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged

Comments

@Turskyi
Copy link

Turskyi commented Jan 13, 2024

Page URL

https://dart.dev/language/constructors.html

Page source

https://github.com/dart-lang/site-www/tree/main/src/language/constructors.md

Describe the problem

The examples on the ‘Constructors’ page (https://dart.dev/language/constructors) currently place fields before constructors. This is inconsistent with the Dart and Flutter style guides, which recommend placing constructors first in a class. This inconsistency could potentially lead to confusion for developers, especially those who frequently switch between Dart and Flutter projects.

Expected fix

Reorder the constructors in all examples on the ‘Constructors’ page to align with the Dart and Flutter style guides. Specifically, adhere to the guidelines from ‘sort_constructors_first’ (https://dart.dev/tools/linter-rules/sort_constructors_first) and ‘Constructors come first in a class’ (https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#constructors-come-first-in-a-class).

Additional context

This issue was raised following a pull request (#5452) that aimed to align the examples with the official style guides. The discussion in the pull request highlighted the tradition of placing fields before constructors in Dart, which is more familiar to developers from other programming languages. However, given the close relationship between Dart and Flutter, it’s worth considering the impact of these stylistic differences on the developer experience. This issue aims to gather feedback from the community on this matter.

I would like to fix this problem.

  • I will try and fix this problem on dart.dev.
@Turskyi Turskyi added the from.page-issue Reported in a reader-filed concern label Jan 13, 2024
@huycozy huycozy added st.triage.triage-team Triage team reviewing and categorizing the issue a.language Relates to the Dart language tour p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. e1-hours Can complete in < 8 hours of normal, not dedicated, work and removed st.triage.triage-team Triage team reviewing and categorizing the issue labels Jan 16, 2024
@huycozy huycozy changed the title [PAGE ISSUE]: 'Constructors' Reorder constructors and fields in code example on Constructors page Jan 16, 2024
@atsansone atsansone self-assigned this Jan 23, 2024
@atsansone atsansone added the st.triage.ltw Indicates Lead Tech Writer has triaged label Jan 23, 2024
@natebosch
Copy link
Member

This is inconsistent with the Dart and Flutter style guides, which recommend placing constructors first in a class.

I don't believe we have or intend any recommendation for the ordering of fields and constructors in a class.

Specifically, adhere to the guidelines from ‘sort_constructors_first’ (https://dart.dev/tools/linter-rules/sort_constructors_first)

This lint is not specifically recommended by the Dart team, and we do not intend to follow it in Dart team authored code.

and ‘Constructors come first in a class’ (https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#constructors-come-first-in-a-class).

Note that this guide is intended to apply specifically to the Flutter repository, and is not authored with the intention of guiding projects in other repositories.

@atsansone atsansone added the cl.wont-fix Issue closed as it either can't be or won't be fixed label Apr 19, 2024
@atsansone
Copy link
Contributor

Closing this issue as Won't fix.

@atsansone atsansone closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
@Turskyi
Copy link
Author

Turskyi commented Apr 19, 2024

Hello @natebosch and @atsansone,

I appreciate your engagement with the issue I raised regarding the ordering of constructors and fields in Dart documentation. I understand that the closure of the issue indicates a decision has been made, but I would like to address some points for clarity and future reference.

Regarding the lint sort_constructors_first, while it may not be a part of the Dart team's recommended set, its presence on the official Dart website and previous attribution to the Dart team suggests that it reflects a practice that is at least recognized, if not endorsed, by the Dart team. This, coupled with the absence of a counter-lint or explicit guidance to place constructors after fields, led me to believe that aligning constructors before fields would be a beneficial change for consistency across Dart and Flutter projects.

I understand that traditions and practices evolve, and what might have been a standard at one point can change. However, I believe that documentation, especially for a language as widely used as Dart, plays a pivotal role in setting standards and best practices for developers to follow.

I respect the decision to maintain the current ordering in the Dart documentation. Still, I hope that this conversation can serve as a reference for any future discussions on the topic, and I remain open to contributing to such dialogues.

Thank you for your time and consideration.

Screenshot 2024-04-19 at 6 24 59 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.language Relates to the Dart language tour cl.wont-fix Issue closed as it either can't be or won't be fixed e1-hours Can complete in < 8 hours of normal, not dedicated, work from.page-issue Reported in a reader-filed concern p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants