Use of word subclass
-
Summary: Why does the Qt documentation use the word “subclass” when there is a more appropriate and well known word: inherit?
In the Qt documentation the authors use this example phrase, captured from an explanation about signals and slots:…but we can always subclass widgets to add our own signals to them.
As I see it the word subclass is not appropriate.
In math, B is a subclass of A if and only if all the elements of B are in A. Adding new elements to B while retaining all the A elements makes B a super set of A. By the definition of the word subclass it is no longer a subclass of A.
In programming we use inheritance, Z inherits from Y and adds to Y. It never detracts from Y. Z is never a subset of Y, it is always a superset of Y. (If Z is the same as Y then just use Y and forget Z.) I hold that the analogy between “set” and “class” is valid and therefore the words “subset” and “subclass” should also hold the equivalent meanings.
Maybe there is something I don’t understand. Please enlighten me. -
@BKBK It's just wording and not related to math in this case :-)
A is a class, B is a class - common wording in OOP is that if B inherits from A it is a subclass of A.
So, you should not mix it with what subclass means in math. -
@jsulm said in Use of word subclass:
@BKBK It's just wording and not related to math in this case :-)
A is a class, B is a class - common wording in OOP is that if B inherits from A it is a subclass of A.
So, you should not mix it with what subclass means in math.Its more than just wording. Words do matter. The prefix "sub" indicates a smaller portion of, not an enlargement of. A sub assembly is never larger than the assembly. A sub station is a smaller station. A SUBtraction makes a smaller value, not larger.
And flat out no, they are not synonyms.
Do a google search with the phrase: definition of prefix sub
a prefix occurring originally in loanwords from Latin ( subject; subtract; subvert; subsidy ); on this model, freely attached to elements of any origin and used with the meaning “under,” “below,” “beneath” ( subalpine; substratum ), “slightly,” “imperfectly,” “nearly” ( subcolumnar; subtropical ), “secondary,” “ ...
All of the variations are in contradiction with the use questioned here.
The OP wondered if there is a meaning of which I might be unaware. At this point I don't think so. The use of subclass in the context presented is simply wrong. It is misleading and should not be used.
-
It is a common term used throughout computer science. As is the term superclass to describe a parent class. It describes a relationship between classes. It does not denote magnitude in the computer science use:
https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)#Subclasses_and_superclassesEvery science has its own jargon. Math jargon is not the same as computer science jargon. Medical jargon has its own as well. Subclass is used in biology to denote a relationship between organisms. Not to denote magnitude of one organism to another. Yes the usage of sub may be imprecise, but English is not precise. It has hundreds of exceptions. Jargon is an attempt within the domain it is used to be more concise/precise. So in computer science subclass is used to describe a specific relationship in inheritance. As is superclass. In CS it is precise because that is the way CS is taught. You will always find collisions of meaning of terms in different domains.
-
I was curious as I didn't think "sub" was so narrowly defined. So I looked it up:
https://www.merriam-webster.com/dictionary/subThe first usage case for sub is:
under : beneath : belowThis is the usage for subclass. The class inheritance chain is generally represented as a class hierarchy where the parent classes appear to be above the sub classes in the diagram. So moving up the inheritance chain is moving to a superclass, while moving down is moving to a subclass.
Achievement Gained: Dead horse beaten
-
@BKBK said in Use of word subclass:
The use of subclass in the context presented is simply wrong. It is misleading and should not be used.
That's your opinion. I disagree, I've seen it floating around for as long as I can remember.
@fcarney, just to get some life into your dead horse (i.e. playing the devil's advocate a bit):
2.4.6 Derived Classes
The derived class concept is C++’s version of Simula’s prefixed class notion and thus a sibling of
Smalltalk’s subclass concept. The names derived class and base class were chosen because I
never could remember what was sub and what was super and observed that I was not the only one
with this particular problem. It was also noted that many people found it counterintuitive that a
subclass typically has more information than its superclass. In inventing the terms derived class
and base class, I departed from my usual principle of not inventing new names where old ones
exist. In my defense, I note that I have never observed any confusion about what is base and what
is derived among C++ programmers and that the terms are trivially easy to learn even for people
without a grounding in mathematics.http://www.stroustrup.com/hopl2.pdf
@fcarney said in Use of word subclass:
The class inheritance chain is generally represented as a class hierarchy where the parent classes appear to be above the sub classes in the diagram. So moving up the inheritance chain is moving to a superclass, while moving down is moving to a subclass.
Yeah, that's how I've learned it during the stone age, and it's still true if you've read reputable sources. As it so happens, however, I've seen it backwards, and for some, that has created countless cases of confusion between "upcasting" and "downcasting".
-
@fcarney said in Use of word subclass:
I was curious as I didn't think "sub" was so narrowly defined. So I looked it up:
https://www.merriam-webster.com/dictionary/subThe first usage case for sub is:
under : beneath : belowThis is the usage for subclass. The class inheritance chain is generally represented as a class hierarchy where the parent classes appear to be above the sub classes in the diagram. So moving up the inheritance chain is moving to a superclass, while moving down is moving to a subclass.
Achievement Gained: Dead horse beaten
That, just maybe, presumes that when we diagram a class and derived class we draw a circle or square for the original, then draw a connection line downward with the derived below it. I suggest that the derived be drawn above it. The derived one springs forth from the original and enhances or improves it. Therefore it should be drawn above it.
But: That's not going to happen.
Achievement Gained: One more pound of flesh from that dead horse.I think this demonstrates a major human attribute that causes no end to problems. Once we learn something one way, are taught something one way, then we are extremely reluctant to change our minds. Facts make no difference. I do not exclude myself from this propensity. But I try.
So now I conclude, and in my not so humble opinion, the use of the word “subclass,” in the context presented, is wrong, but has no hidden or subtle meanings that I have missed. That is the way some, even many, people write.Edit: We do not walk beneath the feet of those that preceded us and showed the way. We stand on their shoulders and see ever further.
-
@BKBK said in Use of word subclass:
Its more than just wording. Words do matter. The prefix "sub" indicates a smaller portion of, not an enlargement of. A sub assembly is never larger than the assembly. A sub station is a smaller station. A SUBtraction makes a smaller value, not larger.
The sub prefix in this context is "below" rather than meaning that it is smaller. In the sense that it's below the parent type in a hierarchy of types. Like a squad is below a Lieutenant in a military hierarchy, even if the squad collectively weighs much more that the Lt. Or a particular narrow field of study might be a 'subfield.' For example, Quantum Chromodynamics is a subfield of Physics. QCD experts will be familiar with all the generally applicable jargon of Physics like mass and energy, but also have a lot of specialist jargon that is unique to their subfield that a general Physicist isn't necessarily familiar with.
Life is full of jargon that seems unfamiliar when we first encounter it. But it's usually more useful to learn the jargon than to try to convince a whole industry to change the way that talk about things because you personally find a different term clearer.
-
@JonB said in Use of word subclass:
To me it's just like you have class in the Animal Kingdom and then a subclass, or a species and then a subspecies. Who inherit certain features and may have others of their own.
As you follow those lineages in the Animal Kingdom, the count of species gets smaller and smaller. There the word subclass is appropriate because the higher levels are indeed super class.
That supports my position. Thank you. -
@JonB said in Use of word subclass:
So now I conclude, and in my not so humble opinion, the use of the word “subclass,” in the context presented, is wrong
Made me laugh :) You're wrong, but Happy Xmas!
My position is supported by facts. (Being the definitions of the words) The use of subclass rather than inherited or derived does not have facts other than the fact that people like to write it that way. Therefore I conclude my position is correct.
And Merry Christmas, Happy New year, and any other phrase you prefer. -
@BKBK said in Use of word subclass:
As you follow those lineages in the Animal Kingdom, the count of species gets smaller and smaller.
The count has nothing to do with anything. It's related to hierarchy - you go from the more general to the more specific in taxonomy. The ginko tree is the one and only one extant species of the Ginkgophyte order, are you going to suggest the order's demoted just because it had the rotten luck to currently contain only one living species?
Same reasoning applies in class hierarchy in programming as well. The base class is a generalization of a concept that's more specific in derived classes (if they exist). Your argument about "sprouting out of" and "count matters" is faulty. Just live with it.
-
@kshegunov said in Use of word subclass:
@BKBK said in Use of word subclass:
As you follow those lineages in the Animal Kingdom, the count of species gets smaller and smaller.
The count has nothing to do with anything.
The count is extremely important. By the definition of the prefix "sub" and the words inherit and derived, the use of subclass to reference derived or inherited classes, classes that are larger and more comprehensive, is incorrect. As we have two perfectly good words, inherit(ed) and derive(d), why would anyone want to use a word that, by its definition, does not fit.
As noted in post 9 (I think it is post 9) once started down the wrong path many, or even most, people will go to extreme lengths to avoid the realization that they made a mistake. I may not change anyone's mind, but I am right. -
@BKBK said in Use of word subclass:
I may not change anyone's mind, but I am right.
If you take this approach to language, you'll never be able to communicate with anybody. Language, by its nature, is an emergent property of consensus of the way that people communicate in practice. Aside from the very widely understood etymology of subclass in this context, charging into a community of people who understand each other and insisting that you are right in a way that nobody else agrees with just isn't a useful approach to language in general. If you start digging up etymologies of every word, you decide that they are 'wrong.'
"Compiler" can only mean a program that assembles chunks of existing code and not a program that transforms code from high level to machine language, for example. "Broadband" can't refer to high speed Internet. "Internet" can't refer to a specific network. "Bandwidth" can't refer to the speed of a data link. "Word" can only refer to an element of spoken language, not the length of a register. "Byte" can't be assumed to be 8 bits, or maybe Byte just isn't a real word at all. "Computer" can only refer to a human being employed to do mathematics for a living. I can make dramatically stronger arguments about the 'wrong' usage of every single one of those words than about the word "subclass." But if we did that, we'd be stuck just grunting and pointing at things and shrugging our shoulders because none of our words are good enough to satisfy 100% mutually consistent logical rules across all fields of application. Because natural human language just isn't something constructed out of 100% logical and systematic rules. Sometimes the sense of a word is just different in a different context.
-
@BKBK said in Use of word subclass:
The count is extremely important.
No it's not. Quantity and quality are different things. Arguing that quantity signifies quality is bogus. Generalizations (what inheritance treats) deal with quality, and are not a quantitative characteristic.
By the definition of the prefix "sub" and the words inherit and derived, the use of subclass to reference derived or inherited classes, classes that are larger and more comprehensive, is incorrect.
"Sub-", as already explained to you, in this context means "below" (not "smaller") and it's, as again already explained, used because of the usual way of putting generalizations on top of the things they relate to - that is to encompass what they generalize. Rationally there is no significant reason that this is like this beside historical reasons.
I can define anything the way I want to. I can define 600nm light to be "green", and I'd be just as right as long as people understand what I mean when I say "green light". Definitions, just because they're that - definitions, are arbitrary and not subject to proof.
As noted in post 9 (I think it is post 9) once started down the wrong path many, or even most, people will go to extreme lengths to avoid the realization that they made a mistake.
It's called confirmation bias, and it's not the case here.
I may not change anyone's mind, but I am right.
You'd think that, wouldn't you? Well, it's your right to think so, but it's also everybody else's right to think what you think is wrong.
-
@JonB said in Use of word subclass:
Guys, I think & presume we are to take @BKBK's comments with a certain amount of Festive Cheer and tongue-in-cheek-ness. :)
All, I should not have made my last comment about being right. That was inappropriate. I would edit it but that would make other posts appear inconsistent. Rather I extend my apologies.