Version 1 (modified by sderle, 7 years ago)

--

OpenLayers Coding Standards

Writing Code

  • Variables, properties, and methods are named in lowercase or camelCase. Classes are Uppercased or StudlyCapped. Constants are named in ALL CAPS.
  • All identifiers should be long enough to be understandable and unambiguous. For example, zoomHasChanged is preferable to zlch. By contrast, lat and lon are sufficient for latitude and longitude properties on the OpenLayers.LonLat class, because they are unambiguous.
  • Indent is K&R style, four spaces. No tabs! (If you're running vim, set expandtabs.)
  • OpenLayers uses the JSAN standard for laying out source files. Ideally, this means one class per file under lib/, with the file name broken out, one directory level per namespace, e.g. OpenLayers.Layer.WMS -> lib/OpenLayers/Layer/WMS.js.

Writing Unit Tests

  • All the tests for a given class go in tests/test_ClassName.html or tests/test_Class_SubClass.html.
  • When adding a new test file, be sure to list it in tests/list-tests.html.
  • If you add a new class or a new method to a class, consider writing a test for it. It'd be great if our unit test coverage converged on 100%.

Committing to Subversion

  • Be sure all the unit tests in source:/trunk/openlayers/tests/run-tests.html pass before committing to trunk. (If you're committing to your own sandbox, you can break whatever you like.)
  • Each code commit should focus on a single set of changes to the code base. If you make a number of changes to different files for different reasons, please make multiple commits, with a different log message for each.
  • Please make your commit logs as verbose as possible!

Managing Tasks in Trac

  • When you start working on a ticket from Trac, be sure to assign that ticket to yourself, so that everyone else knows who's working on it.
  • When you mark a ticket fixed in Trac, be sure to mention the revision(s) (e.g. r73) that contain the fix.

Thank you for contributing to OpenLayers!