-
Notifications
You must be signed in to change notification settings - Fork 4
Code Conventions
Naming conventions: Local Variables naming convention states that it is better to use underscores rather than camelBack for multiple word names, e.g. mileage, variable_xyz, no camelCase
Instance Variables Instance variables are defined using the single "at" sign (@) followed by a name. It is suggested that a lowercase letter should be used after the @, e.g. @colour
Instance Methods Method names should start with a lowercase letter, and may be followed by digits, underscores, and letters, e.g. paint, close_the_door
Model The model is named using the class naming convention of unbroken MixedCase and is always the singular of the table name, e.g. table name might be orders, the model name would be Order. Rails will then look for the class definition in a file called order.rb in the /app/models directory. If the model class name has multiple capitalised words, the table name is assumed to have underscores between these words.
Controller Controller class names are pluralized, such that OrdersController would be the controller class for the orders table. Rails will then look for the class definition in a file called orders_controller.rb in the /app/controllers directory.
Many to Many Link Tables Tables used to join two tables in a many to many relationship is named using the table names they link, with the table names in alphabetical order, for example items_orders.
Code conventions: -Two Spaces, No tabs -Keep lines to a reasonable length(80 characters is classical but 100-120 is probably acceptable with screen sizes these days) -Method names should be intuitive and meaningful -Methods should not exceed 50 lines. Divide into two methods if they do. -Variable names should be intuitive and meaningful -Before creating any method, one should check it is not already built-in in the respective programming Language. You can find a list of available ruby methods here: http://www.tutorialspoint.com/ruby/ruby_builtin_functions.htm You can find a list of available javascript functions here: http://www.tutorialspoint.com/javascript/javascript_builtin_functions.htm
- when adding a new gems in the gemfile, it is very important to add the version of the gem next to the gem name in order to use compatible gems for later usage.