[webkit-dev] For your consideration: Naming scheme for fooIfExists/ensureFoo
fpizlo at apple.com
Sun Jun 30 21:39:10 PDT 2013
Sent from my PDP-11
On Jun 19, 2013, at 9:41 AM, Dan Bernstein <mitz at apple.com> wrote:
> On Jun 19, 2013, at 7:37 PM, Timothy Hatcher <timothy at apple.com> wrote:
>> What about?
>> StyleResolver* existingStyleResolver()
>> StyleResolver& styleResolver()
> I like it.
>> — Timothy Hatcher
>> On Jun 19, 2013, at 11:49 AM, Balazs Kelemen <kbalazs at webkit.org> wrote:
>>> For me optional seems very misleading and generally different prefixes suggests that those objects are not the same.
>>> Maybe IfExists does not sound nicely but at least it's clear. I would choose to have a pointer version with IfExists and a reference version which is a noun, like:
>>> StyleResolver* styleResolverIfExists()
I like this more. I like that the use of 'if' in the name alerts me to the fact that the function will return something conditionally.
By contrast, "existingFoo" only makes sense to me if I'm already aware of the idiom. And although I probably will *become* aware of the idiom it will still nonetheless be one of many idioms that I have to be aware of, so I fear that I'll forget why "Foo" is qualified with "existing". That's why I like "fooIfExists" - its super explicit about what is going on.
>>> StyleResolver& styleResolver()
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
More information about the webkit-dev