Labs/Bespin/CodingStyle
Jump to navigation
Jump to search
JavaScript
JavaScript code should follow the Crockford Code Conventions. With a few minor modifications:
- **Namespaces**: Crockford does not mention namespaces, probably because owning the global namespace allows you to use as much as you want. Our code is likely to be used in many different places so we should not pollute the global namespace needlessly. We would like to reduce our namespace usage to Bespin.*
- **_private**: We agree that prefixing variables with an underscore provides no actual protection, however we think of it as a warning. "Use of this member is unsupported and likely to break without warning in future revisions". In early versions of Bespin where we are experimenting a lot, allowing 3rd parties to join in the experiment is valuable. As Bespin becomes more stable and finalized, we might expect underscored members to be replaced with closure scoped variables.
- **var at top**: The standard recommends putting var statements as the first statements in the function body, although we note that Crockford doesn't always follow his own advice. We reserve the right to intend to follow his lead ;-)
Students of our existing code may observe that we don't currently follow our own guidelines in all places. We hope to fix this problem as we go along.
Python
The coding standards for Python are easy: PEP8
Java
Likewise Java coding standards are easy: Sun's Java Conventions