Skip to content

Coding conventions

NicolasPetton edited this page Feb 14, 2013 · 16 revisions

Formatting

  • Always put a space before and after a binary selector, as well as inside blocks.
  • Properly indent your code using tabs, not spaces (the current IDE makes it difficult, we're not picky there).
  • No unnecessary parenthesis.
  • No unnecessary blank lines, expect after the method comment, temps declaration, or 'guard' statements, such as shouldReturn ifTrue: [ ^ self ]..
  • Always use yourself in cascades.
  • Use each as an argument name of iteration blocks.
  • Add a space at the beginning and end of a temporary variable declarations and blocks.
  • Avoid unnecessary statement separators.
  • Close multiple blocks on one line, exception can be made for #ensure: and #on:do: blocks
  • Keep methods as short as possible (up to ~5 lines is ok).

Method protocols

  • Private methods go to the 'private' protocol
  • Initialization methods go to the 'initialization' protocol
  • Accessing methods go to the 'accessing' protocol
  • Error methods go to the 'error handling' protocol

Comments

  • The first comment of a method should state the use of the method. Keep it short, but ensure that these are valid sentences starting with an uppercase letter and end with a full stop.
  • Avoid comments within the method body when not needed or intention revealing.
  • Class comments are mandatory
  • Referring to Github issues is OK in method comments, but not in class comments.

Initialization

  • #initialize should always send super initialize

(This page is freely adapted from Seaside coding conventions

Clone this wiki locally