list icon indicating copy to clipboard operation
list copied to clipboard

Style guide for workshoppers

Open mmwtsn opened this issue 9 years ago • 3 comments

Thoughts on adding a suggested style guide for the workshoppers source code?

I have been enjoying going through them but have found the code samples formatting inconsistent. It's not a huge deal but considering that this could be someone's first introduction to Node.js development it would be nice to be able to say "Hey, here's how we recommend you format your code."

Code style could be incorporated as an early lesson in learnyounode. This should be fairly straightforward for the user if an npm-distributed formatter is suggested like Standard.

mmwtsn avatar May 13 '15 15:05 mmwtsn

While generally not a bad thought it is a very religious issue you are trying to kick off here.

martinheidegger avatar May 13 '15 16:05 martinheidegger

I'm less interested in a holy war than I am in consistency.

Here's an example solution from expressworks:

var express = require('express')
var app = express()

app.use(require('stylus').middleware(process.argv[3]));
app.use(express.static(process.argv[3]));


app.listen(process.argv[2])

While this is a trivial example the quality of the solution could be improved by running a simple linter over it.

Given how NodeSchool presents itself and its workshoppers it makes sense that they would all be formatted similarly. The Go team summarized quite nicely on their blog where they outline the benefits consistently formatted code:

  • easier to write: never worry about minor formatting concerns while hacking away,
  • easier to read: when all code looks the same you need not mentally convert others' formatting style into something you can understand.
  • easier to maintain: mechanical changes to the source don't cause unrelated changes to the file's formatting; diffs show only the real changes.
  • uncontroversial: never have a debate about spacing or brace position ever again!

Put that way it really isn't terribly controversial. Making a decision at the workshopper level saves individual contributors from having to have these conversations or entertain style-based pull requests.

For what it's worth npm will be using Standard moving forward.

mmwtsn avatar May 13 '15 17:05 mmwtsn

@mmwtsn I have no problem with coding standards. I just wanted to prepare you for the discussion you are bringing yourself into.

martinheidegger avatar May 13 '15 18:05 martinheidegger