[webkit-dev] Terminology for giving up ownership: take, release, move

Alfonso Guerra huperniketes at gmail.com
Tue Sep 6 09:14:36 PDT 2016

On Tue, Sep 6, 2016 at 4:29 AM, Daniel Olegovich Lazarenko <
danielo at opera.com> wrote:


> * "take" - a typical name for collections like a blocking queue, heap and
> some others (usually ordered). If it's a collection's method, it's
> logically expected to return an item. The key distinction between
> fred.takeCandy() and say bowl.takeCandy() is that bowl is passive.

That doesn't make sense to me. Why would the object "bowl" be passive, but
not "fred"?

We treat bowl as a passive bag of data, and expect others to take from it.

I see. Like an actual bowl in the real world?

> It's pretty easy to understand and remember, it makes intention more clear
> than say "bowl.removeCandy()".

Not to me. When I read or write object-oriented code, I think of it as
sending messages of what I want done to the object. I see the object as
being an intermediator performing actions on behalf of the caller.
Containers and collections are classes that group a set of functions the
caller needs done, so it's more convenient to view them as being a
mediator, if you will, for the caller.

I think trying to map real-world behaviors into object interfaces is trying
too hard to mirror the real world. I see it as imposing additional
cognitive load on comprehension by requiring me to remember if it's passive
or not. In fact, if it's passive that would violate the OOP and real-world
paradigms: why would I be sending it a message?

Especially in this day and age of smart appliances and IoT I think it's
more consistent to think of the bowl as a "smart" bowl that responds to my
messages. "Give me all the green candy", "sort candy by size", etc.

> Pure OOP style is always the right way when it comes to readability. A
> good example mentioned by Stroustrup once that it should be sqrt(5), not
> 5.sqrt().

Do you have a link for that? The closest thing I see to that example (
https://isocpp.org/blog/2014/12/myths-2) is demonstrating the exact
opposite, that a non-OOP solution provides better performance by
eliminating the dereferencing of a pointer.

> Naming is fun.

Learning how to communicate across cultures of all types is fun. ;-)

Alfonso Guerra
Apokalypse Software Corp.
(626) 667-4285
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20160906/86bd3129/attachment-0001.html>

More information about the webkit-dev mailing list