codex
Good and bad practices from life experience.
Content
- Introduction — few words about the Codex.
- Naming — a section about naming stuff.
Introduction
codex
is a handbook about code, architecture and things in-between.
Want to contribute? Read the short guide before you do.
Naming
Some examples of odd and bad class naming from one project:
/*
`RichComboBoxComboBox` is a class, that represents `ComboBox` DOM element.
*/
class RichComboBoxComboBox extends ComboBox { /* ... */ }
/*
`RichComboBox` is a class, that represents form input with validation
and other logic.
*/
class RichComboBox extends CompositeFormInputEl {
constructor() {
// Composition: `RichComboBoxComboBox` inside `RichComboBox` to control the
// visual representation with client logic.
this.comboBox = new RichComboBoxComboBox();
}
/*
Later, class was renamed `RichComboBoxComboBox` -> `LoaderComboBox`,
because it uses lazy loading, provided by `Loader`.
*/
/*
View (representation, DOM element) of `FormOptionSet` for items of type `Options`.
*/
class FormOptionSetOptionView extends FormItemView { /* ... */ }