Closed Bug 168910 Opened 22 years ago Closed 22 years ago

[meta] replace the hardcoded contract id with placehold

Categories

(Core Graveyard :: Embedding: APIs, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: Henry.Jia, Assigned: adamlock)

References

Details

It's not a good idea to use hardcoded contract id, such as
"@mozilla.org/embedcomp/window-watcher;1" instead of NS_WINDOWWATCHER_CONTRACTID.

First, the code style is not good.

Second, it is more easy to be wrong using the literal than the placehold.

Third, if the literal changed someday, you may need to change it everywhere.
Although this may not be easy to happen.

Also for convenience of bug 154047
Add some experts here.
I'm not a big expert, but: Would this change have any influence to the performence?
Depends on: 158080, 158608, 159889
Since the change is like this: 

#define NS_WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"

and use NS_WINDOWWATCHER_CONTRACTID instead of
"@mozilla.org/embedcomp/window-watcher;1" later, 

there should not be performance loss.
The only valid argument for making changes like this is so that you can bump the
contract ID "version" easier.  I am not sure that may people care about this
task as it yields nothing.  Instead, I would hope that we could move to use cid
where possible.  This has the possibly of reducing data and speeding up mozilla.  
(There is, though, an argument that, *if* we're going to use ContractIDs rather
than CIDs, it's better to use macros than writing the strings directly because
it means that a typo will be a compile-time error rather than a (much slower to
fix) run-time error.  This argument doesn't apply so much to modifying existing
code, though.)
I don't want to start a big CID vs. ContractID debate but I think if someone
wants to replace hardcoded contractIDs with macros, it would be fine... but I
would rather that that person's time be spent on something that improves mozilla
rather than just cleaning up code appearence.

According to the above comments, let's take this issue as a relax work. When we
want to relax ourself, we can do this work.
Closing out this bug. Raise bugs to cover specific instances
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
verified
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.