[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfriends-ml 12068] Re: 「 Java 2 Standard Edition 5.0 Tiger 」を 読む会第1回議事録



高橋(徹)です。

   ""TAKAHASHI, Tomohiro" <t_takahashi@xxxxxxxxxxxxxx>"さんは書きま
した:
> snip 
> >    - 1.2.1の命名規約の出典はどこだろう?→宿題
> snip

>   他(仕様書など)にも書かれているのでしょうか??
http://java.sun.com/docs/books/jls/
The Java Language Specification, Third Edition(Java言語仕様第3版)の
6.8.3 Type Variable Namesに命名規約が記述されています。

---引用---
"Type variable names should be pithy(single character if possible)
yet evocative, and should not include lower case letters."

"Container types should use the name E for their element type. Maps
should use K for the type of their keys and V for the type of their
values. The name X should be used for arbitrary exception types. We
use T for type, whenever there isn't anything more specific about 
the type to distinguish it."

"If there are multiple type parameters that denote arbitrary types,
one should use letters that neighbor T in the alphabet, such as S.
Alternately, it is acceptable to use numeric subscripts(e.g. T1, T2)
to distinguish among the different type variables. In such cases,
all the variables with the same prefix should be subscripted."
---引用---

簡単にまとめると、
・型変数の名前は可能な限り単一文字で小文字は含めない
・コンテナの要素には'E'を用いる。
・Mapの場合、キーに'K'、値に'V'を用いる
・任意の例外型には'X'を用いる
・上記のどれかに具体的に特定できない任意の型には、'T'を用いる
・複数の任意の型を用いる場合、'T'の近隣のアルファベット(例えば'S')
  を用いるか、数値を後ろに付けて区別する(例えばT1, T2)。


--
TAKAHASHI,Toru
torutk@xxxxxxxxxxxx