[webkit-dev] For your consideration: Naming scheme for fooIfExists/ensureFoo

Elliott Sprehn esprehn at chromium.org
Wed Jun 19 16:22:29 PDT 2013


On Wed, Jun 19, 2013 at 9:46 AM, Andreas Kling <akling at apple.com> wrote:

> On Jun 19, 2013, at 6:37 PM, Timothy Hatcher <timothy at apple.com> wrote:
>
> What about?
>
> StyleResolver* existingStyleResolver()
> StyleResolver& styleResolver()
>
>
>
This doesn't make sense since calling styleResolver() again won't create a
new one so it's also "existing style resolver".

I rather like the foo() and ensureFoo() methods. foo() is just a plain
getter like any other method, the class may start with:

setFoo(Foo*);
Foo* foo();

later we want to also allow optionally created when needed so we add:

Foo* ensureFoo();

The current naming and methodology makes a lot of sense. fooIfExists()
always bugs me because there's no reason to decorate a getter that is just
a plain getter. Adding an ensureFoo() method shouldn't make me rename the
existing foo() method to fooIfExists().

- E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130619/507d0150/attachment.html>


More information about the webkit-dev mailing list