Interface names
By convention, one-method interfaces are named by the method name plus the -er_suffix: Read_er, Writer, Formatter etc.
There are a number of such names and it’s productive to honor them and thefunction names they capture. Read
, Write
, Close
, Flush
, String
and soon have canonical signatures and meanings. To avoid confusion, don’t give yourmethod one of those names unless it has the same signature and meaning.Conversely, if your type implements a method with the same meaning as a methodon a well-known type, give it the same name and signature; call yourstring-converter method String
not ToString
. 16
当前内容版权归 Miek Gieben 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Miek Gieben .