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

doc: add "Troubleshooting" & "best practices" #12791

Closed
wants to merge 8 commits into from

Conversation

refack
Copy link
Contributor

@refack refack commented May 2, 2017

More discussion on the "Rules of thumb" is in #12744

Help wanted: let's find these "tips" a better home 🏡

Fixes: #12636

[edit]

As I understand the term "rules of thumb" or "best practices", they are guidelines one should have in mind and try to adhere to, but are not necessarily hard requirements. Our requirements should be stated in the other parts of the document.

[/edit]

My suggestion for a few "rules of thumb" for code contributions.
These are obviously my personal opinion, so this PR welcomes edit and suggestions. I do think that we should put some loose guidelines in writing.

The following made me think of this, and are not critique!
Ref: #12603 - motivation
Ref: #12735 - size

Open questions:

  1. A significant amount of the first-time contributors don't look at this document at all. So is this the best place to put this?
  2. Are some of these not just rules of thumb but rather requirements that are better moved to appropriate places of the document.

Add a "catch all" document for tips & trick.
When adding an item, try to include the original error message or some keyword so that this doc will popup in Search.

Ref: #12786

Checklist
Affected core subsystem(s)

doc

/cc @vsemozhetbyt @gibfahn

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label May 2, 2017
@refack refack added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label May 2, 2017
@addaleax addaleax added the wip Issues and PRs that are still a work in progress. label May 2, 2017
@refack refack removed the wip Issues and PRs that are still a work in progress. label May 2, 2017
@refack
Copy link
Contributor Author

refack commented May 2, 2017

@addaleax I commented out the "Tricks" section so there is no TBD in the doc. IMHO it could land as is, and enhanced as we go


### Windows

1. If you regularly build on windows, you should check out [`ninja`](./building-node-with-ninja.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

### Windows

1. If you regularly build on windows, you should check out [`ninja`](./building-node-with-ninja.md).
You may find it to be much faster than `MSBuild` and less eager to rebuild unchanged sub-targets.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length.

## Troubleshooting

1. Python crashes with `LookupError: unknown encoding: cp65001`
This is a known `Windows`/`python` bug ([_python bug_][1], [_stack overflow_][2]). The simplest solution is to set an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length.

@refack
Copy link
Contributor Author

refack commented May 2, 2017

@vsemozhetbyt fixed

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented May 2, 2017

Maybe this is a nice and handy hotchpotch addition to the docs as we do not maintain our Wiki)

@refack
Copy link
Contributor Author

refack commented May 2, 2017

Maybe this is a nice and handy hotchpotch addition to the docs as we do not maintain our Wiki)

Exactly

@refack refack changed the title doc: add "Tips, Tricks & Troubleshooting" doc: add "Troubleshooting" & "rules of thumb" May 2, 2017
@refack refack mentioned this pull request May 2, 2017
2 tasks
@refack
Copy link
Contributor Author

refack commented May 2, 2017

/cc @nodejs/documentation

@Fishrock123
Copy link
Contributor

I'm not sure whether or not it might be, so... is "rules of thumb" an overly "english" colloquialism? Would there be a better phrase / title?

Note: I know what it means.

@refack
Copy link
Contributor Author

refack commented May 5, 2017

Sometimes the phrase "best practices" is used in it's stead.

## Rules of thumb

<details>
<summary><strong>Provide motivation for the change</strong></summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these work in files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. If you regularly build on windows, you should check out [`ninja`]. You may
find it to be much faster than `MSBuild` and less eager to rebuild unchanged
sub-targets.
P.S. non-windows developers may also find it better then `make`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is faster on both platforms, might want to just mention it alltogether

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. it's just that on windows the difference is amazing!

@refack refack changed the title doc: add "Troubleshooting" & "rules of thumb" doc: add "Troubleshooting" & "rules of thumb"/"best practices" May 5, 2017
@@ -0,0 +1,74 @@
# Tips, Tricks & Troubleshooting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This title seems a bit too vague. I'm not fond of junk-drawer documents (that is to say, a document you throw information in when you don't know where else to put it). So I'd prefer a specific title.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not being cheeky but) do you have a suggestion? (Please don't say FAQ...)
Maybe "Tips & Best Practices"

P.S. usually the main problem with the "junk drawer" is finding stuff, but here we have the search function, for example if you search unknown encoding: cp65001 this will pop up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Tips and Troubleshooting for Fhqwhgads where Fhqwhgads is some specific activity? Like, is it "Tips for Proposing Pull Requests"? Maybe it's more broad than that, but some kind of thing that at least provides context for someone coming from Google that this isn't about troubleshooting running Node.js in production or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's good. I'll figure it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Called it "Tips & Troubleshooting for working with the node code"
Move the "Best practices" to a different doc

@refack refack changed the title doc: add "Troubleshooting" & "rules of thumb"/"best practices" doc: add "Troubleshooting" & "best practices" May 5, 2017
[2]: https://github.com/nodejs/node/blob/master/.eslintrc.yaml "eslintrc"
[3]: https://github.com/nodejs/node/tree/master/tools/eslint-rules "Our Rules"
[4]: https://github.com/nodejs/node/blob/master/doc/STYLE_GUIDE.md "MD Style"
[5]: https://blog.gitprime.com/why-code-churn-matters "Why churm matters"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Churn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obv


## Tips

1. If you build the code often, you should check out [`ninja`]. You may
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ninja may not need code highlight.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to ` wrap program names, but in this case, I agree it makes more sense not to

## Tips

1. If you build the code often, you should check out [`ninja`]. You may
find it to be faster than `make`, much much faster than `MSBuild` (Windows), and less eager to rebuild unchanged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we break this line at 80 chars?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccache makes more of a difference in build speed than ninja, in my experience

Copy link
Contributor

@sam-github sam-github left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks helpful to me.

I suggest adding a section explicitly saying that if you are proposing a new or changed API, that you include docs, because its much easier to review code that has docs. And maybe mention as a meta-goal for the PR "making it easy to review and accept".

I think this could be helpful as a link in the PR template, so it might be found at the time its most relevant.

@@ -0,0 +1,38 @@
# Best Practices
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make heading be full title? "Best Practices for a Successful PR"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@@ -0,0 +1,38 @@
# Best Practices
<sub>(a.k.a "Rules of thumb")</sub>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this adds anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a search keyword trap

## Tips

1. If you build the code often, you should check out [`ninja`]. You may
find it to be faster than `make`, much much faster than `MSBuild` (Windows), and less eager to rebuild unchanged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccache makes more of a difference in build speed than ninja, in my experience


[1]: http://bugs.python.org/issue1602 "python bug"
[2]: http://stackoverflow.com/questions/878972/windows-cmd-encoding-change-causes-python-crash "stack overflow"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should removing trailing whitespace

@refack
Copy link
Contributor Author

refack commented May 8, 2017

I suggest adding a section explicitly saying that if you are proposing a new or changed API, that you include docs, because its much easier to review code that has docs.

Good 👍

And maybe mention as a meta-goal for the PR "making it easy to review and accept".

Yea it's definatly one of the goals of the doc, I'll put it explicitly.

I think this could be helpful as a link in the PR template, so it might be found at the time its most relevant.

Maybe, but IMHO it might be too late. We need to catch them when they start conceptualizing a PR 🤔

<sub>(a.k.a "Rules of thumb")</sub>

## Provide motivation for the change
Try to explain why this change will make the code better. For example, does
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a blank line under each heading? Some Markdown renderers require that.

@@ -0,0 +1,38 @@
# Best Practices for a Successful PR
<sub>(a.k.a "Rules of thumb")</sub>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Sam, this should be removed.


## Provide motivation for the change
Try to explain why this change will make the code better. For example, does
it fix a bug, or is it a new feature, etc. This should be expressed in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a sentence fragment?

## Don't make _unnecessary_ code changes
_Unnecessary_ code changes are changes made because of personal preference
or style. For example, renaming of variables or functions, adding or removing
white spaces, and reordering lines or whole code blocks. These sort of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a sentence fragment.

[code churn][5] As part of the project's strategy we maintain multiple release
lines, code churn might hinder back-porting changes to other lines. Also when
you change a line, your name will come up in `git blame` and shadow the name of
the previous author of that line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not a fan of this entire paragraph. Some small, especially first, but meaningful contributions would fall under these categories – I would say anything that improves the codebase should be welcome; whether those changes are necessary or not is a completely different question.

you change a line, your name will come up in `git blame` and shadow the name of
the previous author of that line.

## Keep the change-set self contained but at a reasonable size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still a typo: self-contained

the previous author of that line.

## Keep the change-set self contained but at a reasonable size
Use good judgment when making a big change. If a reason does not come to mind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: judgement

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even I thought so. Apparently "judgment" is also valid it seems :-|

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, TIL :D feel free to disregard this then

Use good judgment when making a big change. If a reason does not come to mind
but a very big change needs to be made, try to break it into smaller
pieces (still as self-contained as possible), and cross-reference them,
explicitly stating that they are dependent on each other.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might help to know what you mean by “pieces” – different commits, different PRs, or something else? I am not sure how specific you can get here without conflicting with “use good judgement”, but this sounds a little vague. If in doubt, remove the extra text – just saying that contributors should keep in mind that their changes will need to be reviewed in some way should help with most of the trouble that comes from large changes.

[style-guide][1] should make your code
compliant with our linter.
* For JS we use this [rule-set][2]
for ESLint plus some of [our own custom rules][3].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t really think most people can figure out our code style from looking at the actual ruleset – looking at surrounding code or other files should be much easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add that.

@refack
Copy link
Contributor Author

refack commented May 8, 2017

In my mind the best-practices doc should be a conceptual guide to help the contributor better design their PR. IMHO it's not requirements, but rather advice with the goal of "making it easy to review and accept", and reduce surprises and frustration down the road.

For the harder requirements we have CONTRIBUTING.md

I'll add this "disclaimer"

@BridgeAR
Copy link
Member

Ping @refack

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Aug 29, 2017
@refack
Copy link
Contributor Author

refack commented Sep 12, 2017

Need some follow up, but time is limited.

@refack refack closed this Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doc: link to code style guide
10 participants