[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
questions about conventions for GUI preferences
From: |
John W. Eaton |
Subject: |
questions about conventions for GUI preferences |
Date: |
Fri, 25 Oct 2019 02:28:16 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
In some cases, the names and default values of GUI preferences are
defined as symbolic constants in header files. For example, in
gui-preferences-ws.h:
const gui_pref
ws_hide_tool_tips ("workspaceview/hide_tools_tips", QVariant (false));
In a few recent changesets, I tried to use these symbolic names that are
already defined in a consistent way. I noticed a case where the key
name was used as the default value and another where the identifier for
a font size was used where a font name should have been. I also spotted
an incorrect use of a literal preference key.
We also have many literal character strings used for preference keys. I
came up with the attached list.
I saw (and fixed) at least one case where we had a symbolic constant
defined with a key name and default value but the default value was
repeated literally in the code so changing the value in the symbolic
constant wouldn't have had any effect. Having constants defined in
multiple places seems bad to me.
It also seems odd that we would have (for exmample) a symbolic name for
the variable editor font size but not the font name. Why?
Should we try to define and use constants for all preference keys and
default values, use literal strings everywhere, or some mixture as we
have now?
With symbolic constants, it's harder to have typos in the strings used
in various locations.
With symbolic constants, it's easier to know exactly what the key is
without having to search but it's harder to ensure that there aren't any
typos in the names and harder to change the name of a key. Not that it
matters too much, because it is already hard to change the name if you
want to preserve backward compatibility with preference files from
previous versions.
Comments?
jwe
prefs.txt
Description: Text document
- questions about conventions for GUI preferences,
John W. Eaton <=