Last Revised: February 6, 2011
Standards:
There are a number of standards the code conforms to. I'll just list a few
that I can think of off the top of my head:
* RedCloth
This simple mark-up package is used throughout the site, e.g. in user-supplied notes,
in scientific names, and in "internationalization" strings (see below).
* sanitize or html_escape
All user-supplied text should be run through +sanitize+ or +html_escape+ to
strip out any potentially harmful HTML. (Note +h+ is an alias for
+html_escape+.)
* Internationalization
All text should be internationalized. It's very easy: instead of printing a
string literal, print :some_tag.l instead and insert that string into
lang/ui/en-US.yml. More details are given in README_TRANSLATIONS.
* No Model.method() calls in views!
This is a violation of the MVC architecture. Ask Nathan about it. Or check
out the link under the *Ruby on Rails* section near the top of this document.
* Clean Code
We try to use what we believe are the best practices for code development.
Currently that means we like things like "agile methodology", "clean code"
and "test driven development". There is a great deal of information out on
the web about all of these terms. A good book about it "Clean Code" by Robert
Martin. While all the methods pretty much apply in Ruby, that book uses Java
as it's primary example language. A short summary of the key rules are:
1) It is better to contribute than to be intimidated by any of the following
rules.
2) Boy Scouts Rule: Leave the code cleaner than you found it.
3) Only checkin code that passes all the tests.
4) Do Not Repeat Yourself.
5) Keep functions and classes small and well named.
6) Avoid needing documentation. Refactor instead.
7) Write tests for every bug you fix and every feature you add.
8) Test Driven Development is encouraged, but not required.
We are also happy to discuss and revise these rules.