I'm wondering if there is a name for the pattern of defining a generic class with one type argument where the type inherits the defining class.

For example

public class A<T> where T : A<T>

I'm not sure if there even is a name for this. Any help would be much appreciated, thanks.

  • 1
    Just out of curiosity, what would be a use case for this?
    – Flater
    Commented Aug 10, 2018 at 9:37

2 Answers 2


Yes, this pattern is called Curiously Recurring Template Pattern (CRTP), at least in C++. Some call it Curiously Recurring Generic Pattern (CRGP) or simply Recurring Generic Types in java. The general language independent term is F-bound polymorphism.


No naming convention for this pattern exists.

  • Keeping an abstract name like T might be fine for very small or very abstract classes.
  • If the type parameter has some meaning in the business domain, consider using that name for clarity. E.g. if your business domain has a Frobnicator concept, you might choose the names class AbstractFrobnicator<Frobnicator>.
  • You could also choose a name that indicates the parameter is a derived class, e.g. Foo<Derived> or Foo<Self>. I'd prefer this over T for larger classes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.