Lets bike shed!

For some time, functions with names like fooIfExists and ensureFoo have been 
bothering me. I find both names kind of opaque and unpleasant. Here’s an 
example:

    StyleResolver* styleResolverIfExists();
    StyleResolver* ensureStyleResolver()

What do you think of these names instead?

    StyleResolver* optionalStyleResolver();
    StyleResolver& requiredStyleResolver();

I like them better. Note also that I think the requiredStyleResolver function 
should return a reference so nobody is tempted to do null checks. It seems like 
the C++ community likes the name optional for this concept; isn’t there some 
kind of std::optional template?

-- Darin
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to