Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-02-28 05:46:04


Terje Slettebø wrote:

>> You don't need to know the template parameters to know that it
>> is a *pair*. That's the big difference. The template parameter is an
>> abstract concept. Detached from the parameters, it is still a pair.
>> The same does
> not
>> hold for managed<T>. What is "managed"? It is not even a noun
>> without the qualifiers.
>
> Good point, it's not a noun. "resource_manager", "manager" or
> "resource" are nouns, so they may be better.
>
>> managed<widget> // does this *manage* the actual rendering into
>> the window?
>>
>> Gotcha! No it doesn't!
>
> To adjust it so it becomes a noun:
>
> manager<widget>
>
> Manager of widget. It's kind of implied that what is managed is the
> resource itself, even though "resource" doesn't say anywhere. This is
> similar to that you think it's implied that resource<widget> means it
> manages the resource, even though "manage" doesn't say anywhere.
>
> By the way, I used "widget" in the meaning of "anything", as it's
> used some places (like "foo" and "bar").

Look at it this way. Which noun best describes the following:
1) You acquire it
2) You release it
3) You transfer its ownership

A) manager
B) resource
C) managed

> "resource_manager" starts to look attractive, again. ;)

Perhaps. But there's a *better* and *shorter* alternative that very well fits
the description. We can say: linear_list_of_items_manager<int>, YUCK!
Instead, we say list<int>. The management *is* implicit!

Also, in general, I would say that any name suffixed by "_manager" are best
used for classes that manage *many* things simultaneously, NOT JUST ONE.
Take a window_manager for example. It is something that manages the operations
of many windows. In the Macintosh, for example, the resource manager manages
"all* the resources in an application.

--
Joel de Guzman
joel at boost-consulting.com
http://www.boost-consulting.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk