views:

181

answers:

3

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...?)

A: 

Its a good question. I try to name all my interfaces and classes using nouns. So I'd probably end up names like ITrackingTarget, IObservee. Timestamp is at interesting one. Perhaps ITimestamp itself?

Using the Visitor pattern, what would you call the interface that denotes an object which accepts an IVisitor?

Mark Glasgow
Visitable?
dfa
VisitableObject ? VisitorUser ?
neuro
+5  A: 

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

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.

dfa
Though I generally also follow this pattern, "able" doesn't always cleanly fit some more complex ones - for example, IDeterminesEmptyValue. Could be ICanDetermineEmptyValue. IEmptyValueDeterminable doesn't make as much sense.
Rex M
I like your overall reasoning, but "Loggable" is too distant a word from timestamp for my taste.
Jason S
@Jason: I must admit that Loggable is a little *forced* as name :-)
dfa
A: 

I tend to use nouns too.

For an object that can be opened/closed, you can always use the verbose OpenableObject or OpenableInterface : You end up with a noun even if composed.

As it is verbose (and a bit silly) I tend to use Openable instead of OpenableObject. I use OpenableInterface if I want to emphazise the fact that it is an interface.

For objects that use the dependencies inversion pattern I sometimes use the "User" suffix : ImageUser, LoggerUser, ServiceXUser, ...

It is better to use nouns, but I prefer clarity over strict adherence to the rule.

neuro