[Project_owners] Question: Mozilla Development

Alex Vincent ajvincent at gmail.com
Thu Mar 24 08:34:32 EST 2005

> When developing Moz code what editor do you use?

On Windows, I typically use NoteTab Light.  On Linux, nedit seems pretty cool.

> What platform do you use for primary development?

Whatever I feel like.  (Lately, it's been all Windows XP, but I'll be
buying a second hard drive and putting Fedora Core 4 on it.)
> If you are writing some js code let's say this bit below:
> var prefs = Components.classes["@mozilla.org/preferences-service;1"].
>                      getService(Components.interfaces.nsIPrefBranch);
> How would you actually write this code?

const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
var prefs = Components.classes[...].getService(nsIPrefBranch);

> Copy and paste it from somewhere else?

LXR is my friend.
> How do you obtain the contractID or interface to use to instantiate a
> component?

This is usually the part I hate -- I have to go looking for the
contractID.  (It's rarely in the IDL file for the interface.)  But I
wrote a little tool (Object Inspector, inspired by DOM Inspector's
JavaScript Object panel), which lets me play with the properties of
any object I choose, so I can go that way.  I can go the LXR route
> How about if you were writing a new XUL file from scratch, how would you
> do it?

That's the easiest one.  I have built, at home, a set of "minimal"
markup files.  minXUL.xul has just the necessary framework to start
off a XUL document.  I have a couple variations as well (minXHTML.xml,
minXULDialog.xul, minXBL.xml, XBL+.xul for XBL + CSS + XUL).  I
haven't done one for RDF yet.

> Let's say you wanted to add the code below, how would you do it?
>    <toolbarbutton type="menu">
>      <menupopup>
>        <menu>
>          <menupopup>
>            <menuitem />
>          </menupopup>
>        </menu>
>      </menupopup>
>    </toolbarbutton>

Not enough context; what are we adding it to?  (My point is, I try
several different ways until I find one that works.)

> Same with css, let's say you wanted to add some style rules to an element:
> #foo
> {
>    -moz-image-region: rect(0, 388px, 20px, 292px);
> }
> Is the rule "-moz-image-region" committed to memory or a search and
> paste action?

For that particular rule, as for most rules, I have to look it up.

> I'm very curious to see how everyone does things. How the act of
> actually writing the code works for different people.

There's a couple other things I also do.

For instance, because I work a lot with XML languages (some of which I
create), and especially the DOMs for these languages, I started
declaring my languages' namespace URIs as global constants in all
capital letters, postfixed by _NS:

const XHTML_NS = "http://www.w3.org/1999/xhtml";
const XLINK_NS = "http://www.w3.org/1999/xlink";
const XMLNS_NS = "http://www.w3.org/2000/xmlns/";
const XUL_NS = "..."; /* you get the idea */

This becomes extremely handy with the DOM Level 2 Core methods (which
were all about namespaces).

Sometimes, if I have more than a basic set of them, I'll include a
special namespaces.dtd file through my doctype declaration:

<!DOCTYPE dialog [
  <!ENTITY % namespaces.dtd SYSTEM
"chrome://abacus/content/tools/namespaces.dtd"> %namespaces.dtd;
<!-- ... -->

Finally, with Abacus, I developed my assert/warn code -- and if I ever
try to own another big extension project like it, you can bet I'll
reuse that code!  (For Abacus, I also built a couple other JS-based
tools which proved rather useful.)
"The first step in confirming there is a bug in someone else's work is
confirming there are no bugs in your own."
-- Alexander J. Vincent, June 30, 2001

More information about the Project_owners mailing list