workshopper / list

A central catalog of existing, planned and requested workshoppers
14 stars 7 forks source link

Style guide for workshoppers #37

Open mmwtsn opened 9 years ago

mmwtsn commented 9 years ago

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.

martinheidegger commented 9 years ago

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

mmwtsn commented 9 years ago

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.

martinheidegger commented 9 years ago

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