[Development] [Qt5-feedback] A micro API review: for V3(md5) and V5(sha1) in QUuid
lars.knoll at nokia.com
lars.knoll at nokia.com
Fri Dec 9 13:38:17 CET 2011
On 12/9/11 1:27 PM, "João Abecasis" <joao.abecasis at nokia.com> wrote:
>
>Lars wrote:
>> On 12/9/11 12:28 PM, "ext liang.qi at nokia.com" <liang.qi at nokia.com>
>>wrote:
>>>
>>> The original task is:
>>> http://bugreports.qt.nokia.com/browse/QTBUG-23071
>>>
>>> And the change is:
>>> http://codereview.qt-project.org/10803
>>>
>>> For the API name, we need a micro API review:
>>> Set 1:
>>> createUuidMd5()
>>> createUuidSha1()
>>>
>>> or
>>>
>>> createUuidMd5OrSha1()
>>>
>>> Set2:
>>> createUuidV3()
>>> createUuidV5()
>>>
>>> or
>>>
>>> createUuidV3OrV5()
>>>
>>> Any other suggestion is also welcome.
>>
>> These names look ugly. Why not simply QUuid::createUuid(const QUuid &ns,
>> const QByteArray &baseData, Version v); ?
>
>I don't like that one since the namespace and name version only makes
>sense for v3(Md5) and v5(Sha1), making all other options useless. I would
>prefer one name that makes explicit either the version (v3/v5), the
>approach (fromName) or the hash function (Md5, Sha1).
>
>This has my vote:
>
> QUuid QUuid::createFromNameV3(const QUuid &, const QByteArray &);
> QUuid QUuid::createFromNameV5(const QUuid &, const QByteArray &);
>
> inline QUuid QUuid::createFromName(const QUuid &ns, const QByteArray
>&name)
> {
> // SHA1 (v5) is recommended
> return createFromNameV5(ns, name);
> }
>
> inline QUuid QUuid::createFromName(const QUuid &ns, const QString
>&name)
> {
> return createFromName(ns, name.toUtf8());
> }
A lot better.
The other option (if you want to avoid having two symbols is to only have
createFromName(Š, Version = Sha1), and document that anything that's not
Md5 will use to Sha1.
I don't have strong opinions on either option though.
Cheers,
Lars
More information about the Development
mailing list