Index: openacs-4/packages/acs-core-docs/www/style-guide.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/style-guide.html,v diff -u -N -r1.24.2.1 -r1.24.2.2 --- openacs-4/packages/acs-core-docs/www/style-guide.html 18 Jun 2010 21:29:36 -0000 1.24.2.1 +++ openacs-4/packages/acs-core-docs/www/style-guide.html 12 Dec 2010 00:07:03 -0000 1.24.2.2 @@ -1,7 +1,12 @@ +<<<<<<< style-guide.html OpenACS Style Guide

OpenACS Style Guide

+======= + +OpenACS Style Guide

OpenACS Style Guide

+>>>>>>> 1.26 By Jeff Davis -

Motivation

+

Motivation

Why have coding standards for OpenACS? And if the code works why change it to adhere to some arbitrary rules?

@@ -10,7 +15,7 @@ lines of tcl code, about 460,000 lines of sql (in datamodel scripts and .xql files), about 80,000 lines of markup in .adp files, and about 100,000 lines of documentation. All told, just - about a million lines of "stuff". In terms of logical units + about a million lines of "stuff". In terms of logical units there are about 160 packages, 800 tables, 2,000 stored procedures, about 2,000 functional pages, and about 3,200 tcl procedures. @@ -26,10 +31,10 @@ over a long period by a lot of different people, OpenACS sometimes lacks this basic guessability and in the interest of bringing it into line we have advanced these guidelines. -

Commandments

+

Commandments

Here is a short list of the basic rules code contributed to OpenACS should follow... -

  1. Follow the file naming and the package structure rules.  +

    1. Follow the file naming and the package structure rules.  Some of the file naming rules are requirements for things to function correctly (for example data model creation scripts and tcl library files must be named properly to be @@ -38,25 +43,25 @@ if ignored won't break anything, but if you follow the rules people will be able to understand your package much more easily. -

    2. Be literate in your programming.  +

    3. Be literate in your programming.  Use ad_proc, ad_library, and ad_page_contract to provide documentation for your code, use comments on your datamodel, explain what things mean and how they should work. -

    4. Test.  +

    5. Test.  Write test cases for your API and data model; test negative cases as well as positive; document your tests. Provide tests for bugs which are not yet fixed. Test, Test, Test. -

    6. Use namespaces.  +

    7. Use namespaces.  For new packages choose a namespace and place all procedures in it and in oracle create packages. -

    8. Follow the constraint naming and the PL/SQL and PL/pgSQL rules.  +

    9. Follow the constraint naming and the PL/SQL and PL/pgSQL rules.  Naming constraints is important for upgradability and for consistency. Also, named constraints can be immensely helpful in developing good error handling. Following the PL/SQL and PL/pgSQL rules ensure that the procedures created can be handled similarly across both Oracle and PostgreSQL databases. -

    10. Follow the code formatting guidelines.  +

    11. Follow the code formatting guidelines.  The code base is very large and if things are formatted consistently it is easier to read. Also, if it conforms to the standard it won't be reformatted (which can mask @@ -65,27 +70,33 @@ easier to read and manage and does not force other programmers to decipher what tab settings you had in place in your editor. -

    12. Use the standard APIs.  +

    13. Use the standard APIs.  Don't reinvent the wheel. Prefer extending an existing core API to creating your own. If something in the core does not meet your particular needs it probably won't meet others as well and fleshing out the core API's makes the toolkit more useful for everyone and more easily extended. -

    14. Make sure your datamodel create/drop scripts work.  +

    15. Make sure your datamodel create/drop scripts work.  Break the table creation out from the package/stored - procedure creation and use create or - replace where possible so that scripts + procedure creation and use create or + replace where possible so that scripts can be sourced more than once. Make sure your drop script works if data has been inserted (and permissioned and notifications have been attached etc). -

    16. Practice CVS/Bug Tracker Hygiene.  +

    17. Practice CVS/Bug Tracker Hygiene.  Commit your work. commit with sensible messages and include patch and bug numbers in your commit messages.

      Create bug tracker tickets for things you are going to work on yourself (just in case you don't get to it and to act as a pointer for others who might encounter the same problem). -

    18. Solicit code reviews.  +

    19. Solicit code reviews.  Ask others to look over your code and provide feedback and do the same for others. +<<<<<<< style-guide.html

Revision History

Document Revision #Action Taken, NotesWhen?By Whom?
0.1Creation12/2003Jeff Davis
($Id$)
View comments on this page at openacs.org
+======= +

Revision History

Document Revision #Action Taken, NotesWhen?By Whom?
0.1Creation12/2003Jeff Davis
($Id$)
View comments on this page at openacs.org
+>>>>>>> 1.26