[Development] [Qt5-feedback] A micro API review: for V3(md5) and V5(sha1) in QUuid

João Abecasis joao.abecasis at nokia.com
Fri Dec 9 13:27:47 CET 2011


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());
    }

Cheers,


João




More information about the Development mailing list