Ö
Öö Tiib
[...]I do not actually buy that "set" helps with non-property
somehow. For example everybody was born somewhere. Birth place
(a Location) however is not property because it does not
belong to Person.
How is that? It obviously depends on the application, but in
most applications, Location are values (with no behavior or
identity), and each Person has one (and only one) birthplace,
which belongs to him. (In most applications, making Location a
type for birthplace, rather than just using std::string, is
overkill.)
Perhaps i gave bad example. I was more about some sort of state +
region + village as location. Several people are likely born at same
location.
[...]
Regretfully, the naming conventions in the standard library are
horrible. There is certainly no "property" empty for a standard
container---it's arguable that a container doesn't have
properties, in the sense that it manages its data differently.
And functions which are not properties should be verbs. Which
means that by all rights, std::vector<>::empty is a verb, and as
a verb, defines an action. The only correct name in this case
would be is_empty. And clear should do just that: the verb
empty should remove all elements from the vector, and the verb
clear return it to the state it had immediately after
construction. But that would be good design. Not something we
see much of in the standard library.
Yes. Why i brought that up was to display that naming is part of the
art of interface design. Bad names (like std::vector's empty) may
mislead people who use the interface. It is important that policy for
naming does not oversimplify it.