TimurMahammadov / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

com.google.common.base.Join suggestions #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I quickly skimmed through the Javadoc, and have some suggestions that go 
with the Join class that I wanted to discuss:

* Perhaps rename it "Joins". Join.join sounds like possible a Star Wars 
character. If you don't use import static, that is.

* Use Builder (syntax to be discussed):
  Joins.join("a","b","c").with(":");
  Joins.flushJoin("a","b","c").with(":").to(myAppender);

Great work, guys. I will be enjoying this library.

Original issue reported on code.google.com by robbie.v...@gmail.com on 13 Sep 2007 at 10:09

GoogleCodeExporter commented 9 years ago
Thanks for the suggestions.

Since the Join class is heavily used all over Google's Java code, we don't want 
to
rename it unless there's a convincing reason to do so. Your distaste of 
"Join.join"
doesn't quality.

While builders can be helpful, such as our ImmutableMapBuilder, in this case the
existing syntax is more concise and equally clear.
  Join.join(":", "a", "b", "c");

Original comment by jared.l....@gmail.com on 13 Sep 2007 at 10:20

GoogleCodeExporter commented 9 years ago
I agree with Jared.

A large number of overloads does usually indicate a fluent API might help, and 
your
suggestions are quite good.  But... in this case, this is such a basic low-level
utility that I tend to think it's better to keep it very straightforward.  And 
the
fact that we'd have to update all 2300 existing usages in internal Google code 
really
makes this only worth doing if we were *really* sure.

And the name -- I concluded that there is no possible name for this class that I
won't hate; but we went with this and have lived with it for a while... it's 
okay.  I
guess we'll have a whole new dialogue about the name when we try to slam it into
java.util.

make sense, Robbie?  Thanks for the report.

Original comment by kevin...@gmail.com on 1 Oct 2007 at 7:43

GoogleCodeExporter commented 9 years ago
Joining a Map begs for a fluent API in my book because now there are two 
delimeters.
I would also like to see it handle a conceptual Map when I have two related 
lists
such as keys and values.

Original comment by dvy...@gmail.com on 26 Oct 2008 at 3:59

GoogleCodeExporter commented 9 years ago
Actually, Join now has a method that takes a Map as input.

http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/bas
e/Join.html#join(java.lang.String,%20java.lang.String,%20java.util.Map)

Original comment by jared.l....@gmail.com on 27 Oct 2008 at 5:10