Re: Symbol Name Length (Was: STL Memory leak?)
On Apr 13, 5:24 pm, Noah Roberts <n...@nowhere.com> wrote:
Arne Mertz wrote:
James Kanze schrieb:
On Apr 9, 11:21 am, Arne Mertz <n...@arne-mertz.de> wrote:
James Kanze schrieb:
std::list<std::string> optionList;
after some refactoring this is changed to
std::vector<std::string> optionList; //oops.
Encoding the type in the variable's name is duplication of
the type information (and therefore violates the DRY
principle), and it can (and eventually will) lead to
misinformation if the type changes as shown above.
But your example doesn't contain an instance of the type in
name. The object is a list of options; whether the list is
implemented using std::list or std::vector doesn't change
that.
[snip]
But anyways, I think that if any programmer reads the word
"List", the first thing thar comes in his mind is the linked
list.
Actually, and I'm far from a newbie, I didn't get your
illustration because I *didn't* think of "optionList" as
specifying that it was a std::list<>. I didn't think of that
until Kanze said something about it. I just thought, "Oh, a
list of options," in the abstract sense.
I mentionned it because Arne did.
I wonder if there isn't a linguistic question involved here. I
think you're a native English speaker, and I grew up as one,
even if it's been years since I last used English regularly.
The "everyday" sense of list is the first which comes to mind to
us. I don't think Arne is a native English speaker. (He's
posting from a .de address, and his name sounds rather
German---although it wouldn't surprise me if some Americans had
the same name.) His English is obviously very good, but he
probably doesn't have the same feeling for the language a native
speaker would. If most of his use of English is technical
English, in a C++ environment, then his point of view is very
understandable. When I worked in Germany, "List" would have
generally been understood to refer to a concrete type: std::list
in C++, java.util.ArrayList in Java, etc. And I would have
called the variable in question "optionsVerzeichnis", and not
"optionList".
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34