From 30c3aff9827696f0271ef7fac40f091063967d75 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 3 Dec 2012 10:39:35 -0500 Subject: [PATCH] Add some notes on UI code style --- NOTES.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NOTES.md b/NOTES.md index e5e4e156b..9cbca5f87 100644 --- a/NOTES.md +++ b/NOTES.md @@ -106,6 +106,19 @@ the state of the data model objects (Entity, Graph) or their constituent parts ( tags Object) must return a new instance of the appropriate type, leaving the current instance unchanged. +## UI + +Rendering and UI code generally follows d3 styles and conventions. + +Constructor functions typically return a function decorated with additional properties. The function +can be called with `this` set to a d3 selection in order to set up the HTML structure. This is usually +done via [selection.call](https://github.com/mbostock/d3/wiki/Selections#wiki-call). + +Accessors are implemented as a unified getter/setter function. When called with no arguments, +it acts as a getter; when called with an argument it acts as a setter and returns self, for +chaining. Accessors are preferable to constructor arguments; constructors typically take zero +arguments. + ## Performance See blog post: http://mapbox.com/osmdev/2012/11/20/getting-serious-about-svg/