migrator / guava-libraries-2

Guava: Google Core Libraries for Java 1.6+
0 stars 0 forks source link

Should toStringHelper(Class|Object) use simple name or canonical name (or either)? #21

Open migrator opened 10 years ago

migrator commented 10 years ago

For some nested classes you would really rather toStringHelper chose the canonical name "Foo.Bar" instead of just the simple name "Bar".

Questions:

  1. Which is the best default behavior?
  2. If that is the canonical name, would it be evil to change it now? It is perhaps debatable whether the current behavior really is strongly promised by spec. Some overenthusiastic unit tests would have to be changed, but how bad is that?
  3. Does this choice actually merit a new configuration option to ToStringHelper? Note that without it, users who want the opposite behavior will need to change typical (85%) usage code like so:

    toStringHelper(this) --> toStringHelper(getClass().getCanonicalName())

... which is not pleasant. However, we don't want ToStringHelper to become too complex.

relevance: 2

migrator commented 10 years ago

summary: Not Defined

Possibly we should apply our decision here equally to AutoValue. (AutoValue currently appears to use "Bar.")

status Not Defined creator: cpov...@google.com created at: Oct 14, 2014