Wiki

Clone wiki

CANVAS / Naming Policy

Naming Policy



Code

Common elements

Ruby

For Ruby we are using Rubocop to enforce some policies. Example: snake_case for method and variable names, CamelCase for Classe names, etc...

See Code Quality Policy to see how to use rubocop.

Tests

For naming test in ruby, you still need to use snake_case as for other methods.

You must name them like that:

  • test_[class_or_module_name]_[method_name]_[case]
  • [method_name] is optional (ex: if testing class attributes)
  • [case] is optional (ex: test the return value of a method)

Examples:

  • test_scraper_scrap: class=scraper, method=scrap, case=none
  • test for a method with overloading:
  • test_scraper_feeds_noarg: class=scraper, method=feeds, case=noarg (because testing the method without args)
  • test_scraper_feeds_witharg: class=scraper, method=feeds, case=witharg (because testing the method with args)
  • test_feed_attributes: class=feed, method=none, case=attributes (because we are testing the attributes of the feed class)

The previous examples come from here.

File name

File names must match this regex /[a-zA-Z0-9-_.]*/. Don't use fancy characters, replace spaces with underscores _ not hyphens -. Use dots . only for extension purpose.

Also respect some Folder and File Naming Convention (see the link for details):

  1. Avoid extra long folder names and complex hierarchical structures but use information-rich filenames instead.
  2. Put sufficient elements in the structure for easy retrieval and identification but do not overdo it.
  3. Use the underscore _ as element delimiter. Do not use spaces or other characters such as: ! # $ % & ' @ ^ ~ + , . ; = ) (`
  4. Use the hyphen - to delimit words within an element or capitalize the first letter of each word within an element.
  5. Elements should be ordered from general to specific detail of importance as much as possible.
  6. The order of importance rule holds true when elements include date and time stamps. Dates should be ordered: YEAR, MONTH, DAY. (e.g. YYYYMMDD, YYYYMMDD, YYYYMM). Time should be ordered: HOUR, MINUTES, SECONDS (HHMMSS).
  7. Personal names within an element should have family name first followed by first names or initials.
  8. Abbreviate the content of elements whenever possible.
  9. An element for version control should start with V followed by at least 2 digits and should be placed as the last most element. To distinguish between working drafts (i.e. minor revisions) use Vx-01->Vx-99 range and for final draft (i.e. major version release) use V1-00-> V9-xx. (where x =0-9)
  10. Prefix the names of the pertinent sub-folders to the file name of files that are being shared via email or portable storage devices.

Updated