Hi, folks.

I'm looking for guidelines for naming preferences. However, I've never found it yet. I guess that there is no guidelines.

If so, I'd like somebody to create a common guidelines in MDN.



When I work on some bugs, I need to add a new option for a pref switchable behavior, e.g., if we need to add a new option to a feature and the new one isn't enabled in default settings, it's better to add new pref for the additional option in some cases.

I sometimes have trouble about naming a new pref in such situation.

A lot of prefs which just switches a feature disabled or enabled are:

> |foo.a_feature_name|

Then, new pref becomes like:

> |foo.a_feature_name.option|

I feel that this is not good especially following case:

> |foo.a_feature_name|
> |foo.a_feature_name.disabled_on_some_environments|

I think that a pref which enables/disables a feature should end with |.enabled|. Then, above example becomes:

> |foo.a_feature_name.enabled|
> |foo.a_feature_name.disabled_on_some_environments|

The can be defined by a formula:

<general-group>.(<sub-group>.)*<target-feature>.<state>

The <state> shouldn't be omitted.

And also, <sub-group> should be used as far as possible.

For example, some metrics/colors which can be retrieved with LookAndFeel class can be override by hidden prefs. The most hidden prefs are named as |ui.<metricsName>| or |ui.<colorName>|.
http://mxr.mozilla.org/mozilla-central/source/widget/xpwidgets/nsXPLookAndFeel.cpp#26

This causes a trouble.

nsXPLookAndFeel observes every pref. For doing that, it observes *all* prefs under |ui.|.
http://mxr.mozilla.org/mozilla-central/source/widget/xpwidgets/nsXPLookAndFeel.cpp#430

And the observer uses 3 loops for retrieving the pref cache from the arrays.
http://mxr.mozilla.org/mozilla-central/source/widget/xpwidgets/nsXPLookAndFeel.cpp#388

If somebody changes a pref under |ui.| at runtime, every change causes running this expensive method.

So, I think that they should be named as:

> ui.system_metrics.int.<metricsName>
> ui.system_metrics.float.<metricsName>
> ui.system_color.<colorName>

Then, observer never harms performance of other modules.


For preventing these unfortunate things, we should define good guidelines about pref names.


# Anyway, if it's allowed, we should rename the pref names referred from nxXPLookAndFeel even though customized users will need to set them again.

Thanks in advance.

--
Masayuki Nakano <masay...@d-toybox.com>
Manager, Internationalization, Mozilla Japan.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to