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

Allow two line breaks #390

Closed
raphael-boucher opened this issue Jan 20, 2016 · 8 comments

Comments

@raphael-boucher
Copy link

commented Jan 20, 2016

Double line breaks allow to clearly separate large entities, such as classes. Could we allow them ?

@rstacruz

This comment has been minimized.

Copy link
Member

commented Jan 20, 2016

Wouldn't it be better to add comments to separate large entities?

Or even better: break them apart into smaller functions or multiple modules?

@dcousens

This comment has been minimized.

Copy link
Member

commented Jan 20, 2016

multiple modules

This is how you deal with this problem.
If the two swaths of code are tightly coupled, then, its likely you're not abstracting the problem properly.

@raphael-boucher

This comment has been minimized.

Copy link
Author

commented Jan 21, 2016

My point is to separate clearly modules (whatever their size), with the logic one line for a function, two lines for a module.

Taking the following example, these modules are small and a double line break helps to distinguish them.

class Polygon {
  constructor(height, width) {
    this.height = height
    this.width = width
  }

  get area() {
    return this.calcArea()
  }

  calcArea() {
    return this.height * this.width
  }
}


class Point {
  constructor(x, y) {
    this.x = x
    this.y = y
  }

  static distance(a, b) {
    const dx = a.x - b.x
    const dy = a.y - b.y

    return Math.sqrt(dx * dx + dy * dy)
  }
}

The comment idea is interesting, but it feels more like a hack if I don't have a meaningful comment to make.

@caspervonb

This comment has been minimized.

Copy link

commented Jan 21, 2016

The extra new-line is just extra noise IMHO. If your file is large, use syntax based folding.

@dcousens

This comment has been minimized.

Copy link
Member

commented Jan 21, 2016

@raphael-boucher by module, I am referring to a distinct translation unit. That is, a different file.

@yoshuawuyts

This comment has been minimized.

Copy link
Contributor

commented Jan 21, 2016

It seems the concensus of the respondents in this thread is that this should not be adopted for standard, therefor I'm closing this issue. Thanks for bringing it up regardless!

If you'd like to continue discussing this, feel free to do so. This has merely been closed to signal that at least for now a resolution has been found.

@raphael-boucher

This comment has been minimized.

Copy link
Author

commented Jan 21, 2016

Shouldn't the syntax convention be fine for all file sizes, or at least up to 500 lines ?
We don't always want to make several small files when there is the need for a slightly bigger separation. Reasons I can think of are lots of overhead and file coherence.

@yoshuawuyts

This comment has been minimized.

Copy link
Contributor

commented Jan 21, 2016

@raphael-boucher all my .js files are typically <150LOC and definitely <300LOC; anything above that I've found to become brittle. If you're writing long files you might want to look into writing shorter files or start using code folding; I don't think adding extra newlines is a workable solution to make code more readable (see also padded-blocks:never).

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
5 participants
You can’t perform that action at this time.