canmove, Confirmed users, Bureaucrats and Sysops emeriti
2,798
edits
MarkFinkle (talk | contribs) No edit summary |
MarkFinkle (talk | contribs) (added random thoughts on code) |
||
Line 32: | Line 32: | ||
## Hookup events to elements in JS (not XUL) and promote using best practices (commands, keys, and controllers) | ## Hookup events to elements in JS (not XUL) and promote using best practices (commands, keys, and controllers) | ||
## Localization utilities for accessing string bundles | ## Localization utilities for accessing string bundles | ||
== Random Thoughts == | |||
We should put as much code as possible in some form of namespace. Possible names? "MOZILLA" | |||
Accessing services/interfaces/components should be easier. We could allow shorthand access like this: | |||
<pre> | |||
var prefService = Components.classes["@mozilla.org/preferences-service;1"] | |||
.getService(Components.interfaces.nsIPrefBranch2); | |||
// or | |||
var os = Components.classes["@mozilla.org/observer-service;1"] | |||
.getService(Components.interfaces.nsIObserverService); | |||
// or | |||
var cs = Components.classes['@mozilla.org/consoleservice;1'] | |||
.getService(Components.interfaces.nsIConsoleService); | |||
</pre> | |||
These could become: | |||
<pre> | |||
var ps = MOZILLA.getService("@mozilla.org/preferences-service;1", "nsIPrefBranch2"); | |||
// or | |||
var os = MOZILLA.getService("@mozilla.org/observer-service;1", | |||
"nsIObserverService"); | |||
// or | |||
var cs = MOZILLA.getService("@mozilla.org/consoleservice;1", "nsIConsoleService"); | |||
</pre> | |||
Of course, for flexibility, we should allow quick access to classes as well: | |||
<pre> | |||
var prefs = MOZILLA.getClass("@mozilla.org/preferences-service;1"); | |||
// Now you can call getService to whatever you need | |||
</pre> | |||
For commonly used services, we could even have named "getters" like this: | |||
<pre> | |||
var prefBranch = MOZILLA.PrefBranch(); | |||
var os = MOZILLA.ObserverService(); | |||
var cs = MOZILLA.ConsoleService(); | |||
</pre> |