# Naming convention for type parameters

**URL:** <https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546>\
**Category:** Uncategorized\
**Created:** [March 18, 2016, 1:34pm UTC](https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546 "2016-03-18T13:34:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![medium](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/medium/32/10404_2.png) [@medium](https://discuss.kotlinlang.org/u/medium)\
**Post date:** [March 18, 2016, 1:34pm UTC](https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546/1 "2016-03-18T13:34:56Z")

</div>

It looks like Kotlin is sticking with the [Java naming conventions for type parameters](https://docs.oracle.com/javase/tutorial/java/generics/types.html): `T`, `K` for keys, `V` for values and so on. But this convention doesn’t make much sense in general. `K` and `V` looks like a good idea at first, but how fits `T` into the picture? I guess `T` stands for “type”, but `K` and `V` are type parameters as well. It get’s completely absurd when we have some more type parameters not beeing one of the predefined kinds (like “key”), then you would continue with `U` , `V` …

I suggest to establish the [Scala naming convention](http://docs.scala-lang.org/style/naming-conventions.html#type_parameters_generics) starting with `A`. It is simpler and avoids strange things like `V` for “Value” and `V` as successor of `T`.

---

<div class="post-metadata">

**Author:** ![Jonathan.Haas](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@Jonathan.Haas](https://discuss.kotlinlang.org/u/Jonathan.Haas)\
**Post date:** [March 18, 2016, 2:17pm UTC](https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546/2 "2016-03-18T14:17:13Z")

</div>

I don’t see anything strange with the [Java conventions](https://docs.oracle.com/javase/tutorial/java/generics/types.html). Using “Key” instead of “K” is confusing because it looks like a class. And starting alphabetically from A is certainly worse than using abbreviations that make sense (K = Key, V = Value, E = Enum or Element, T = usually any type for containers). Also, Java uses `List<E>` for example while Kotlin uses `List<T>` which is clearer in my opinion.

---

<div class="post-metadata">

**Author:** ![Dittert](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/dittert/32/1736_2.png) [@Dittert](https://discuss.kotlinlang.org/u/Dittert)\
**Post date:** [March 18, 2016, 8:24pm UTC](https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546/3 "2016-03-18T20:24:30Z")

</div>

I have been using full names in in my own Java classes for quite some time (`KEY` or `VALUE`). Works like a charm.

---

<div class="post-metadata">

**Author:** ![valentin1](https://avatars.discourse-cdn.com/v4/letter/v/8797f3/32.png) [@valentin1](https://discuss.kotlinlang.org/u/valentin1)\
**Post date:** [March 25, 2016, 9:57pm UTC](https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546/4 "2016-03-25T21:57:52Z")

</div>

In cases when I feel that a single letter name is not enough for a type parameter and I need a more descriptive name, I use names like “TKey”, “TSomething”. The “T” at the start helps to understand that it’s not a concrete type but a type parameter.

---

<div class="post-metadata">

**Author:** ![medium](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/medium/32/10404_2.png) [@medium](https://discuss.kotlinlang.org/u/medium)\
**Post date:** [May 16, 2016, 6:50pm UTC](https://discuss.kotlinlang.org/t/naming-convention-for-type-parameters/1546/5 "2016-05-16T18:50:43Z")

</div>

Here’s an article about this topic: [Break the Java Generics Naming Convention?](http://vojtechruzicka.com/break-java-generics-naming-convention/)
