Help us define code standards for the School of Webcraft

4 views
Skip to first unread message

Pippa Buchanan

unread,
Nov 29, 2010, 10:06:24 AM11/29/10
to p2pu-w...@googlegroups.com

In order for Webcraft community members to best interact with each other, it will be helpful for us if we define a set of coding and formatting style guides. As well as increasing readability and encouraging best practice around commenting  and code layout, working to standards is a valuable professional skill.

Obviously, there's a range of languages and frameworks that Webcraft developers will work with as they learn and work with code and we can't define approaches to them all. For the present it will be good to work on the first round of descriptions for HTML, CSS and JavaScript.

I'm aware that it's going to be difficult to choose a standard approach that suits everyone's preferences, but we'd be grateful to have your input about suggested coding standards as well as ways to maintain and educate Webcraft developers in their implementation.

Things these standards should cover include capitalization, variable and function naming, indentation, references to original code authors, licenses etc.

It would be great to have specific input from Mozilla developers as well as those working on the P2PU Lernanta project.

Atul Varma

unread,
Nov 29, 2010, 10:29:50 AM11/29/10
to p2pu-w...@googlegroups.com, Pippa Buchanan
I've found that defining standards is particularly hard where JavaScript
is concerned because there are so many different ways one can use it.
Some people or teams, for instance, find closures hard to read and
outlaw them, while others find variables with a leading '_' really ugly
and outlaw those.

Rather than necessarily prescribing one or the other on such sensitive
topics, it might be useful to thoroughly educate folks on the benefits
and drawbacks of each, so that they can choose which way to go depending
on the needs of their project.

That said, I'm a fan of Doug Crockford's JSLint and its "The Good Parts"
option set, but I know lots of folks who aren't, in part because it
prohibits usage of language features that sometimes have perfectly valid
use cases:

http://www.jslint.com/

One particularly nice thing about JSLint, of course, is that it gives
you a programmatic way of verifying code quality. If adopted by P2PU
at-large, you could easily verify how much of your code being written
conformed to your style guide. Even if you go with another style guide,
though, I guess you could write your own verifier.

If you're interested, these are Mozilla's style guidelines, which are
used for Firefox:

https://developer.mozilla.org/En/Mozilla_Coding_Style_Guide

For the Jetpack/Add-on SDK project, we've sort of "subclassed" this
style guide, overriding it in certain places and creating new rules in
others:

https://wiki.mozilla.org/Labs/Jetpack/Reboot/Style_Guide

All in all, I think this is a really tough task for JS. At least with
Python you've got PEP-8, which practically everyone in the community
already follows.

- Atul

> --
> You received this message because you are subscribed to the "P2PU
> School of Webcraft" mailing list. This is a community mailing list for
> discussing ideas and making decisions about the School of Webcraft run
> by Mozilla and P2PU.
>
> To find out more about the project you can visit
> http://p2pu.org/webcraft or http://drumbeat.org/p2pu-webcraft
>
> To post to this group, send email to p2pu-w...@googlegroups.com
> To unsubscribe from this group, send email to
> p2pu-webcraf...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/p2pu-webcraft?hl=en

Pippa Buchanan

unread,
Nov 30, 2010, 5:18:11 AM11/30/10
to p2pu-w...@googlegroups.com
Thanks Atul!

That's the kind of information I was looking for. The fact that JSLint can check up on (at least one version) of code quality is excellent and would be really useful to work with. Though as you say, we could develop our own style guide and verifier.

What do other people have to say?

P*
Reply all
Reply to author
Forward
0 new messages