Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface naming for adjectives

OK, so it's easy to name an interface (or class for that matter) if you can easily think of a noun: User, Window, Database, Stream, etc.

What about an adjective or adjective concept? e.g. something that has a timestamp (HasTimestamp, Timestamped, Timestampable...?) or something that is tracked or watched (Trackable, IsTracked, Watchable, IsWatched...?)

like image 842
Jason S Avatar asked Aug 12 '09 13:08

Jason S


1 Answers

I tend to use -able suffix. There are many good examples of this naming conventions also in the Java library such as:

  • Cloneable
  • Readable
  • Iterable
  • Comparable
  • Observable
  • Closeable
  • Flushable
  • Serializable

For example something that has tags would be named Taggable under this naming convention, something that has a timestamp is Loggable since:

Timestamps are typically used for logging events, in which case each event in a log is marked with a timestamp. In filesystems, timestamp may mean the stored date/time of creation or modification of a file.

like image 184
dfa Avatar answered Sep 30 '22 16:09

dfa