property in C++

Ö

Öö 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.
 
Ö

Öö Tiib

Jerry said:
[ ... ]
Give him a break: English does not seem to be his primary language.
No problem -- Stroustrup isn't an English name.

It's "English-ized" (I think). I don't see umlauts and such anyway.

Stroustrup sounds like some viking name meaning "stroke throat" or
something like that and i do not think there should be umlauts
anywhere in it. Did you expect it be ströü strüp? There are no such
Scandinavian words.
 
J

Jorgen Grahn

Jerry said:
[ ... ]
Give him a break: English does not seem to be his primary language.

No problem -- Stroustrup isn't an English name.

It's "English-ized" (I think). I don't see umlauts and such anyway.

Actually, it's the proper Danish spelling. Some people from the
iso8859-1 world are fortunate enough to have ASCII-only names ;-)

/Jorgen
 
J

Jorgen Grahn

.
1):
LocationRef loc = bob.getBirthPlace();
2):
LocationRef loc = bob.birthPlace();

What i am seeing only wasted letters "get" on case 1) and nothing is
more readable there. I feel such helper parts in name (not necessarily
"get" or "set") might be useful when the name of function is otherwise
unambiguously clear if that is noun or verb (property or command). For
example empty() of std containers is often confused with clear() by
novice programmers and helper parts in names (like "is_empty" and
"clear_up") might therefore be fine on similar cases.

It usually helps to see the full signature of the function:

bool Foo::empty() const;
void Foo::clear();

Here it's pretty clear what they mean. (But of course in the code that
uses them you don't see all of that.)

/Jorgen
 
J

Jorgen Grahn

Jerry said:
Give him a break: English does not seem to be his primary language.
No problem -- Stroustrup isn't an English name.

It's "English-ized" (I think). I don't see umlauts and such anyway.

Stroustrup sounds like some viking name meaning "stroke throat" or
something like that

I can imagine BS relaxing in his room at Bell Labs in 1985, thinking
and idly stroking his throat ...

Actually I expect it to be a place name. Place names ending in -up, -rup,
-torp or -arp in Scandinavia usually mean <Someone>'s farm. For the
<Someone> part you have to be an expert on men's names 1000 years ago.
See for example http://www.jggj.dk/torp.htm

(Apologies for being so obviously offtopic.)

/Jorgen
 
R

Ruslan Mullakhmetov

Jorgen Grahn wrote:
[...]
straustrup's third special edition followed this standard, pardon,
Standard :)
It's Stroustrup, with an 'o' and a capital 'S'. (I'm not normally that
pedantic, but you misspelled it twice.)
Give him a break: English does not seem to be his primary language.

Spelling a person's name correctly has nothing to do with
whether he's English speaking or not. It's more a question of
politeness.

Sorry for late reply. I've had a holiday.

Yes, It was by-word translation from Russian translation of the author
of "The C++ Programming Language" name.

I always misspelling capital letters and even sometimes write something
like "i'am", "i've", "english", "usa" just because of my laziness.

Thank you for your correction.

P.S. Long long time ago I was planing to read Stroustrup's book in
English. When I opened translation I've realized that English one would
be too complicated for me to handle with two languages: English and C++.
 
J

James Kanze

On 31.07.2010 16:51, James Kanze wrote:
P.S. Long long time ago I was planing to read Stroustrup's
book in English. When I opened translation I've realized that
English one would be too complicated for me to handle with two
languages: English and C++.

Be very, very careful about this. The translations aren't
always that good, since the translators aren't always
specialists in the domain---in the original French translation,
there were numerous cases where the resulting French didn't mean
anything, or meant the complete opposite of what the original
English meant. Stroustrup understands the problems, and is
willing to get involved when it is pointed out to him, so the
French edition has been corrected, and recent versions are OK.
But beware.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top