Naming interfaces for persistent values

Posted by orip on Programmers See other posts from Programmers or by orip
Published on 2014-01-21T13:23:05Z Indexed on 2014/08/20 10:32 UTC
Read the original article Hit count: 220

Filed under:
|
|

I have 2 distinct types of persistent values that I'm having trouble naming well.

They're defined with the following Java-esque structure, borrowing Guava's Optional for the example and using generic names to avoid anchoring:

interface Foo<T> {
    T get();
    void set(T value);
}

interface Bar<T> {
    Optional<T> get();
    void set(T value);
}
  • With Foo, if the value hasn't been set explicitly then there's some default value available or pre-set.
  • With Bar, if the value hasn't been set explicitly then there's a distinct "no value" state.

I'm trying to optimize the names for their call sites. For example, someone using Foo may not care whether there's a default value involved, only that they're guaranteed to always have a value.

How would you go about naming these interfaces?

© Programmers or respective owner

Related posts about naming

Related posts about interfaces