关于java:OOP命名法:Curiously Recurring模板模式中完整类型名称的名称是什么?

OOP Nomenclature: what's the name for the full type name in Curiously Recurring Template Pattern?

奇怪的是,循环模板模式是Jim Coplien为其实际泛型参数是派生类的泛型基类命名的:

1
2
class Base<T> { ... }
class Derived: public Base<Derived> { ... }

或者在Java中,例如,可比和Enums:

1
2
3
class Foo implements Comparable<Foo> { ... }
//or
enum Bar { ... } //  which is actually Bar extends Enum<Bar>

现在,这些类的类型名依次是DerivedFooBar

但是,我们如何称呼那些也指定派生的东西,即"derived is-a base","foo implements comparable","bar extends enum"。这不是类型名,而是其他一些。

但是,这个类型名加上派生名的单词是什么?


在Java中,它是用语言规范给出的:

Given a (possibly generic) class declaration C (n ≥ 0, C ≠ Object), the direct superclass of the class type C is the type given in the extends clause of the declaration of C if an extends clause is present, or Object otherwise.

Given a (possibly generic) class declaration C (n ≥ 0, C ≠ Object), the direct superinterfaces of the class type C are the types given in the implements clause of the declaration of C, if an implements clause is present.

所以,它被称为直接超类或直接超接口。它是"奇怪地反复出现"这一事实没有特别的名称。


这是F-边界多态性。F边界是约束:

1
2
interface I<A extends I<A>>
//            ^----------^

它在子类型中显示为

1
class C extends I<C>