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

Maciej Stachowiak mjs at apple.com
Tue Jun 18 21:21:34 PDT 2013


If the semantic is essentially that of a getter that just happens to lazily create what it gets on demand, then I don't think "require" or "required" is needed. It can just be named as a getter. If the side effect is very important and especially if clients ever call the function only for its side effect, then a verb phrase would be better. I am not sure which applies in this case.

 - Maciej



On Jun 18, 2013, at 7:20 PM, Simon Fraser <simon.fraser at apple.com> wrote:

> On Jun 18, 2013, at 7:11 PM, Darin Adler <darin at apple.com> wrote:
> 
>> On Jun 18, 2013, at 7:05 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
>> 
>>> Why don't we call it requireStyleResolver() instead?
>> 
>> I’m warming to this idea. Maybe we can use “require” as a term of art, analogous to the way we use “create”, to mean “create if not already created”.
> 
> Since the fact that it returns a reference implies that it must create something if necessary, the “required” part of the name seems redundant. Why not just
> 	StyleResolver& styleResolver()
> 
> requireStyleResolver() sounds like it would return a bool.
> 
> Simon
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130618/6b000301/attachment.html>


More information about the webkit-dev mailing list