[webkit-dev] For your consideration: Naming scheme for fooIfExists/ensureFoo
Brady Eidson
beidson at apple.com
Mon Jul 1 19:31:43 PDT 2013
On Jul 1, 2013, at 5:27 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
> On Sun, Jun 30, 2013 at 9:39 PM, Filip Pizlo <fpizlo at apple.com> wrote:
> 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.
>
> I concur. Maybe
> StyleResolver* styleResolverIfExists()
> StyleResolver& styleResolver()
> ?
I concur with this.
For this entire discussion, this is where I was hoping it was headed.
Thanks,
~Brady
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130701/2fa8efd1/attachment.html>
More information about the webkit-dev
mailing list