[Development] Re : Re : QRegularExpression work

Davet Jacques davetjacques at yahoo.fr
Tue Jan 24 13:34:01 CET 2012


> Honestly I don't think that "long" names are a bad thing /per se/.

It depends.

I think it's bad for types that are often instantiated as anonymous objects within larger expressions.
Especially for constructors that are often called with just one string parameter, so when used as anonymous objects they "feel" like custom string literals:

  myString.insert( 1, QString("abc") )
  
  myWebView->load( QUrl("http://abc.com") );
  
  int index = myString.indexIn( QRegex("http://.+\.com") );

In such cases it would decrease legibility and distract from the meaning of the overall expression, if the identifiers of the "string literals" had longer expanded names like QUnicodeCharacterString / QUniformResourceLocator / QRegularExpression.

> Qt is full of classes with long names

But most of them are not usually used in the above way.

For QNetworkAccessManager etc., you will likely always instantiate a named variable at the beginning and then work with that.

> The important thing for a name is to be descriptive

The word "regex" is used a lot, both in writing and talking, and is also unambiguous.
It might even be more widely known than the full term "regular expression" (at least it gets ~ 40 % more Google hits).



More information about the Development mailing list