Skip to content
Jason R. Clark edited this page May 27, 2015 · 4 revisions

The Shoes 4 project does not have a tightly-laced style guide. Some kids like to crisscross their laces. Others like straight lines. Some people prefer double knots or puffy tongues or high heels. Still, there are a few guidelines we try to follow. You can help make the code easier to read by following these guidelines whenever they feel comfortable on your feet.

Use Ruby notation for methods coming from Java

JRuby allows the use of Java-style notation for methods called on Java objects. We prefer a Ruby-style notation. Please use

  • object.add_paint_listener block instead of object.addPaintListener(block)
  • composite.background instead of composite.getBackground
  • composite.background = color instead of composite.setBackground(color)
  • button.disposed? instead of button.isDisposed

NOTE: Using Ruby notation sometimes produces surprising results. For example, Swt::Widgets::Composite objects have #getLayout and #setLayout methods. However, they also have a #layout method. This means that composite.layout is not the same method as composite.getLayout.

Rubocop

Work is underway to enable Rubocop on the Shoes project. This will help us to enforce consistent coding practices.

While not yet required by CI, feel free to run rubocop from the root directory to see how your changes fare!