Search · Index

Naming Conventions

Files 

  • Use always is lowercase: file.tcl
  • Separate names with dash “-“:  my-file.tcl
  • Use English as your for your naming (at least if you plan to contribute to the community)
  • Put generic names, such as:
    • my-page-add-edit.tcl
    • my-page-delete.tcl
    • index.tcl
  • Follow the object-action naming convention
    • my-page-delete.tcl
    • NOT delete-my-page.tcl

Procedures (Tcl functions)

  • Usually in lowercase (only in proc callbacks or service contracts you will use TheFirstLetterOfEachWord as uppercase)
  • Separate words with “_”: my_proc
  • Use names that indicates what the procs does, usually not too long
    • my_package::user::add_to_class
  • Always use namespaces
    • The namespace must be the same as the package-key, just that with “_” if applies
      • If package-key is: my-package
      • Then: my_package::add_user
    • Follow the package_key::object::action convention, use
      • my_package::user::add_to_class
      • NOT my_package::add_to_class::user
    • If you have only one action on users you might also use:
      • my_package::add_user_to_class

SQL Statements

  • Lowercase
  • Seperate words with "_": select_users_in_class
  • Use names that indicate what the SQL statement does, or what it returns
    • db_list list_of_unregistered_user_ids {}
    • db_1row user_info {}
    • db_dml update_user_biography {}
  • Preferrably, in db_multirow calls, keep your statement name the same as the multirow name
  • For PL/SQL look here

SQL constraints 

  • Read the document behind the link
  • All constraints have to be named
  • The naming convention for constraints are as follows:
    • Primary Key: tablename_pk (acs_mail_lite_queue_pk)
    • Unique: tablename_columnname1_columnname2_un
    • Foreign Key: tablename_columnname_fk ( acs_mail_lite_queue_pck_fk)
    • Check:  tablename_column_name_ck (acs_mail_lite_co_qu_use_sender_p_ck)
  • Column names can be abbreviated (e.g. pck instead of package_id)

Variables 

  • Lowercase
  • Seperate words with "_": user_id
  • Use names that indicate what the variable contains. If this matches with a database column, use the same name as used for the column in the database.
  • Use the following conventions for variables containing
    • IDs: Append "_id" at the end, like "user_id"
    • Booleans: Append "_p" at the end, like "employee_p" to define if the user is an employee
    • Arrays: Append "_arr" at the end, like "employee_arr". This way you can immediately detect arrays in the code. 

Package Parameters

  • Use camel case, start with uppercase character
  • Example "IndexRedirectUrl"
Previous Month March 2017
Sun Mon Tue Wed Thu Fri Sat
26 27 28 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 (1) 20 21 22 23 24 (1) 25
26 27 28 29 30 31 1

Popular tags

17 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , bgdelivery , bootstrap , bugtracker , CentOS , COMET , CSP , CSRF , cvs , debian , emacs , fedora , FreeBSD , hstore , includelets , install , installation , installers , install-ns , javascript , libthread , linux , monitoring
No registered users in community xowiki
in last 30 minutes
Contributors

OpenACS.org