[Project_owners] Re: class vs contract ids

Pete Collins pete at mozdev.org
Fri Sep 12 10:53:36 EDT 2003

> But a contract ID is not bound to any
> specific implementation, as the CID is, and is thus more general. 
> Instead, a contract ID only specifies a given set of interfaces that it 
> wants implemented, and any number of different CIDs may step in and fill 
> that request. This difference between a contract ID and a CID is what 
> makes it possible to override components."
> <http://www.mozilla.org/projects/xpcom/book/cxc/html/quicktour2.html#1005456>, 
> Creating XPCOM Components book

Ah, that's a great piece of information.  In practicality though, the 
distinction is useless since there are usually no alternative 
implementations found in Mozilla for the same public interface.

Except nsISample:


But even there, two distinctly different contractID's are used to 
identify the implementation classes.

   @mozilla.org/sample;1 (C++)

   @mozilla.org/jssample;1 (js)

Both classes implement nsISample. To make it even more confusing, a 
ContractID is also referred to as a programID.


Pete Collins

More information about the Project_owners mailing list