Unlike regular classes, widgets are used in view templates, so syntax is important. It should be both easy to write, easy to read and not too verbose because similar constructs are meant to be used over and over again.
Widgets aren't postfixed or prefixed.
Inheritance is allowed with some restrictions:
- If class isn't abstract, it should be final.
- Hierarchy should be kept as linear as possible.
Widgets should:
- Have no state.
- Be immutable.
- Unlike other classes, methods that return a clone of the object with some properties modified, aren't prefixed.
- Keep method names as short as possible but don't hurt readability.
The Method that corresponds to boolean attribute should be named after the attribute and accept a boolean flag argument.