Jetpack/Design Guidelines: Difference between revisions

(describe multi-value property pattern)
Line 42: Line 42:
  let panel = new Panel({ content: "...", width: 200, height: 300 });
  let panel = new Panel({ content: "...", width: 200, height: 300 });
  // panel.content, panel.width, and panel.height are defined.
  // panel.content, panel.width, and panel.height are defined.
It should also be possible to construct instances of an object by calling its constructor without the <code>new</code> operator.
let panel = require("panel").Panel();


Properties that don't have to remain constant over the life of an instance should be settable and deletable after construction by directly setting and deleting the properties.
Properties that don't have to remain constant over the life of an instance should be settable and deletable after construction by directly setting and deleting the properties.
Line 87: Line 91:
  // c is removed (it refers to the same instance of a function that was added).
  // c is removed (it refers to the same instance of a function that was added).


It should be possible to construct instances of an object by calling its constructor without the <code>new</code> operator.
let Panel = require("panel").Panel;
let panel = Panel();


Method names should be verbs, e.g. <code>show</code>, <code>post</code>. Property names should be the simplest accurate conventional or idiomatic label for their value (e.g. <code>persistent</code> for the boolean property of a visual feature that specifies whether or not the feature remains visible all the time).
Method names should be verbs, e.g. <code>show</code>, <code>post</code>. Property names should be the simplest accurate conventional or idiomatic label for their value (e.g. <code>persistent</code> for the boolean property of a visual feature that specifies whether or not the feature remains visible all the time).
Confirmed users, Bureaucrats and Sysops emeriti
2,088

edits