Re: inheriting from std::vector bad practice?
* Nick Keighley:
On 3 Apr, 17:16, "Alf P. Steinbach" <al...@start.no> wrote:
* Leigh Johnston:
"Alf P. Steinbach" <al...@start.no> wrote in message
news:hp7p5m$6rb$1@news.eternal-september.org...
* Leigh Johnston:
* Alf P. Steinbach:
* Leigh Johnston:
The only time it is unwise to use public inheritance is if your
class invariant consists of more than just vector's invariant in
which case it might be possible to break your class's invariant by
calling the vector's member functions, but I don't believe this is
the case in your example (i.e. you are simply performing interface
augmentation).
Sorry, that's bullshit. Proper design involves much more.
didn't you start being rude first?
Depends on your definition of "rude", but who cares. I was precise.
<url: http://en.wikipedia.org/wiki/Bullshit#Distinguished_from_lying>
<quote>
"Bullshit" does not necessarily have to be a complete fabrication; with only
basic knowledge about a topic, bullshit is often used to make the audience
believe that one knows far more about the topic by feigning total certainty or
making probable predictions. It may also merely be "filler" or nonsense that, by
virtue of its style or wording, gives the impression that it actually means
something.
In his essay on the subject, William G. Perry called bull[shit] "relevancies,
however relevant, without data" and gave a definition of the verb "to
bull[shit]" as follows:
To discourse upon the contexts, frames of reference and points of
observation which would determine the origin, nature, and meaning of data if one
had any. To present evidence of an understanding of form in the hope that the
reader may be deceived into supposing a familiarity with content.[6]
The bullshitter generally either knows the statements are likely false,
exaggerated, and in other ways misleading or has no interest in their factual
accuracy one way or the other. "Talking bullshit" is thus a lesser form of
lying, and is likely to elicit a correspondingly weaker emotional response:
whereas an obvious liar may be greeted with derision, outrage, or anger, an
exponent of bullshit tends to be dismissed with an indifferent sneer.
</quote>
It's
possible to disagree over what constitutes a good design and whether
something constitutes good design, but in this case it's about the
opposite, a technique that's almost universally recognized as
Bad(TM), so, no discussion.
could you expand on that for the benefit of those of use who are not
quite so wise in C++ design principles?
Huh. Benefits of a bad technique?
[...]
Sorry but that's bullshit. Interface augmentation is a perfectly
valid design practice.
The OP isn't doing interface augmentation by deriving from
std::vector<Point>.
And that's not what you were talking about, your statement about "the
only time it is unwise to use public inheritance", quoted above.
I.e. you're now attacking a strawman argument or a couple of strawman
arguments.
Instead of inventive strawman argumentation you might reasonably and
straigtforwardly ask why, according to me, your earlier statement is
commonly regarded as bullshit.
As opposed to strawman argumentation, which usually leads to negative
outcomes, such questioning might prove the label-affixer (i.e. here
me) wrong, or you could learn something, or whatever, but mostly
positive outcomes from asking.
You are simply full of shit. Hope this helps.
Assume that you're right about my bodily contents. Does that help your argument?
No, it does not: it is a fallacy to attack the person.
no, it's rude but it isn't a fallacy
It depends. When the personal attack is made as an argument (as above) or in
direct support of an argument, then it is a fallacy known as "Personal attack".
When it's made to discredit a person, as the above also was, then it's a fallacy
known as "Poisoning the well". So in a sense you're right. It was not a fallacy,
it was two fallacies, but hey.
<url: http://www.nizkor.org/features/fallacies/index.html#index> has a good
index of common fallacies, including discussion of the two above.
Let's mark this up as Fallacy #1.
I repeat: interface augmentation (which is what my reply was referring
to) is quite valid
Sometimes interface augmentation is a good idea, but in this case there is no
interface augmentation. Mentioning interface agumentation is just a strawman
argument, which is a fallacy. Let's mark this up as Fallacy #2.
and Bjarne Stroustrup agrees.
This is just an appeal to authority.
I've never quite understood why it is wrong to quote people that might
know something about a subject
See <url: http://www.nizkor.org/features/fallacies/appeal-to-authority.html>.
Which is a fallacy even when it's done
properly with references. Let's mark this as Fallacy #3.
The OP is simply
augmenting vector's interface as far as I can tell (not introducing any
new member variables that contribute to an invariant larger than vector's.)
No. std::vector is a generic type, a template type. The OP is not augmenting
std::vector.
he's augmenting std::vector<Point> which *is* a type
Only if you assume that the std::vector<Point> was intentional. We have the OP's
own statement that it wasn't, that it was only an implementation detail, where
only the push_back method was used.
Cheers & hth.,
- Alf