On Tue, Jun 18, 2013 at 6:38 PM, Darin Adler <da...@apple.com> wrote:
> 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(); > requiredStyleResolver sounds as if it's a special (required) type of a style resolver as opposed to the caller requiring it. Why don't we call it requireStyleResolver() instead? Note also that I think the requiredStyleResolver function should return a > reference so nobody is tempted to do null checks. Sounds like a great idea. On Tue, Jun 18, 2013 at 7:03 PM, Emil A Eklund <e...@chromium.org> wrote: > On Tue, Jun 18, 2013 at 6:38 PM, Darin Adler <da...@apple.com> wrote: > > What do you think of these names instead? > > > > StyleResolver* optionalStyleResolver(); > > StyleResolver& requiredStyleResolver(); > > +1, much clearer and the pointer vs reference makes it even more so. > Perhaps enough so that the required prefix could be dropped: > > StyleResolver* optionalStyleResolver(); > StyleResolver& styleResolver(); I think it's important to communicate the runtime cost of ensuring the existence of the object. - R. Niwa
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev