Skip to content

Lint for placing super() last in constructor initializers (Style Guide) #57159

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

Closed
pq opened this issue Feb 6, 2015 · 0 comments
Closed

Lint for placing super() last in constructor initializers (Style Guide) #57159

pq opened this issue Feb 6, 2015 · 0 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented Feb 6, 2015

From the style guide:

DO place the super() call last in a constructor initialization list.

Field initializers are evaluated in the order that they appear in the constructor initialization list. If you place a super() call in the middle of an initializer list, the superclass’s initializers will be evaluated right then before evaluating the rest of the subclass’s initializers.

What it doesn’t mean is that the superclass’s constructor body will be executed then. That always happens after all initializers are run regardless of where super() appears. It’s vanishingly rare that the order of initializers matters, so the placement of super() in the list almost never matters either.

Getting in the habit of placing it last improves consistency, visually reinforces when the superclass’s constructor body is run, and may help performance.

GOOD:

View(Style style, List children)
    : _children = children,
      super(style) {

BAD:

View(Style style, List children)
    : super(style),
      _children = children {
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants