Skip to content

Rhaptos Software Development

Personal tools
You are here: Home » Developer Blog » Ed's Blog » CNX/Rhaptos Coding Standards

CNX/Rhaptos Coding Standards CNX/Rhaptos Coding Standards

Document Actions
Submitted by ew2. on 2008-06-26 11:17. Development

CNX/Rhaptos Coding Standards


As we have more outside development on Rhaptos and Connexions, I think we need to have some minimum coding standards and guidelines.  The main reason for coding standards is to make the code readable and maintainable by developers that come behind the original author.  If we have coding standards, we all need to agree to them and follow them.  They need to be policed at a certain level.  Otherwise, what is the point?  I would like to come up some simple standards we all agree on before the Siyavula development begins.

Coding Standards


We should adopt the python style guide as our coding standards with possibly some documented exceptions.  Examples of exceptions:

  1. Limit lines to 79 characters.  I don't agree with this.  The only reason this would be needed is for printing.  How often is code printed?
  2. Naming conventions
  • Package and Module names should be all lower case with underscores between words.  We are not following this.
  • Function names should be all lower case with underscores between words.  We are not always following this.
  • Arguments to class methods should use 'cls' as the first arguement instead of 'self'.  We are not doing this and I have not seen any code anywhere doing this.
  • Use a leading underscore on the name of all non-public methods.  We are not always doing this.

Comments


Comments in the code are not written for yourself, but for those that come after you.  Comments should be in plain English with a limited amount of abreviations and jargon.  I have heard the argument that if you can't understand the code by reading it, you are a (please select one or more) poor developer/stupid/too slow for this project/etc.   I have found that the main benefit of good comments is helping bring new developers up-to-speed much faster.  Comments on why you did something can also be very helpful when you revisit code you have not worked on in several months/years.  A simple docstring guidelines could be:

  • Each class, non-accessor method and function should have a docstring that explains what it does and possibly why it is doing it.  It should also include a usage example if it is needed.



Re: CNX/Rhaptos Coding Standards

Posted by jccooper at 2008-06-26 12:27
See also: http://rhaptos.org/devblog/nmueller/csg-rhaptos

Re: CNX/Rhaptos Coding Standards

Posted by reedstrm at 2008-06-30 16:06
example of the class of 'override' skin template w/ comments about how and why it's overriding:

https://trac.rhaptos.org/trac/rhaptos/browser/RhaptosSite/trunk/skins/rhaptos_overrides/main_template.pt

Developer Blog
« November 2008 »
Su Mo Tu We Th Fr Sa
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
2008-11-10
13:39-13:39 Suggestion for live site slowness reports
Categories:
Content (55)
Copyright (0)
Deep Code (3)
Development (203)
Markup (22)
Metadata (1)
Printing (7)
Style (9)
Testing (2)
Usability (6)