You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Henri Yandell <ba...@generationjava.com> on 2003/03/06 22:51:04 UTC

[lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

So, summarising the purple thread:


1) Add abbreviate(), merging StringTaglib truncateNicely functionality in
if different.

2) strdiff/strdiffat functionality added, under the names:
differentText and differentAt.

3) camelCaseToUnderscore. Consider addition of this method. I'm tempted to
think this could go in:  StringEscapeUtils, along with javascript, sql-99,
html, xml, java escape methods.

4) Changes to chomp. Basically write a new chomp with correct behaviour.
Change prechomp->getBeforeFirst, chomp->getAfterLast, and other methods to
fit. Change the getPrechomp [aka getAfterFirst] to not return the
separator.


Have I missed anything Alex et al?

Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

Posted by Henri Yandell <ba...@generationjava.com>.

On Thu, 6 Mar 2003, Stephen Colebourne wrote:

> From: "Henri Yandell" <ba...@generationjava.com>
> > 1) Add abbreviate(), merging StringTaglib truncateNicely functionality in
> > if different.
> +1
>
> > 2) strdiff/strdiffat functionality added, under the names:
> > differentText and differentAt.
> +1
> were these the suggested names?

I may have adjusted a touch :) differsAt and remainingDifference. I
modified the names to have more of a similarity.

> > 3) camelCaseToUnderscore. Consider addition of this method. I'm tempted to
> > think this could go in:  StringEscapeUtils, along with javascript, sql-99,
> > html, xml, java escape methods.
> Is a StringCaseUtils called for? It would involve quite a bit of deprecation
> though.

Possibly. But is this really a case method? It seems more of a conversion
one.


Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Henri Yandell" <ba...@generationjava.com>
> 1) Add abbreviate(), merging StringTaglib truncateNicely functionality in
> if different.
+1

> 2) strdiff/strdiffat functionality added, under the names:
> differentText and differentAt.
+1
were these the suggested names?

> 3) camelCaseToUnderscore. Consider addition of this method. I'm tempted to
> think this could go in:  StringEscapeUtils, along with javascript, sql-99,
> html, xml, java escape methods.
Is a StringCaseUtils called for? It would involve quite a bit of deprecation
though.

Stephen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


RE: [lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

Posted by Steven Caswell <st...@caswell.name>.



> -----Original Message-----
> From: Alex Chaffee / Purple Technology [mailto:guru@stinky.com] 
> Sent: Sunday, March 09, 2003 4:25 PM
> To: 'Jakarta Commons Developers List'
> Subject: Re: [lang] Summarising Purple Was: [lang] Adding 
> Purple to StringUtils
> 
> 
> On Sun, Mar 09, 2003 at 04:05:09PM -0500, Steven Caswell wrote:
> > > I think "bisect" is good since it explicitly means "two
> > > parts" rather than "split" which returns many parts.
> > 
> > Wouldn't "removeFromLast" describe the action more succiently than 
> > "bisect" or "divide"?
> 
> "from" is ambiguous... Which is clearer:
> 
>   removeAfterLast("my dog has dog fleas", "dog") -> "my dog has "
>   removeBeforeLast("my dog has dog fleas", "dog") -> " fleas" or
>   bisectBeforeLast("my dog has dog fleas", "dog") -> "my dog has "
>   bisectAfterLast("my dog has dog fleas", "dog") -> " fleas"
> 
> Or is "split" really the right root after all?

Or even
truncateAfterLast(String)
truncateBeforeLast(String)

since isn't that what is really happening?

For some reason I'm uneasy about bisect. But your point about being in
naming hell is appropriate.
So yeah, we should pick something close to the purpose and reserve the right
to change.

> 
> (This is the sort of tough naming decision that becomes clear 
> only after one has used the API in the wild for a while, and 
> (these days) renamed it a few times with a refactoring 
> tool...  So maybe we should just pick one and reserve the 
> right to change our mind before the first release.)
> 
> > > * toUnderscoreName, toCamelCaseName
> > > 
> > I still think these are more functionality than is intended in 
> > StringUtils. Would it make sense to put them into a 
> > StringConvertUtils?
> 
> But there are many "conversion" routines already in 
> StringUtils, so this would create an arbitrary and confusing 
> disjunction (confusing to those trying to figure out in which 
> class a certain method lies).

A good point, and since I don't have much more of an argument, I'll let it
go. I'm fuzzy on where the line is anyway. I just don't want to see the API
to get too out of control.

> 
> 
> -- 
> Alex Chaffee                               mailto:alex@jguru.com
> Purple Technology - Code and Consulting    http://www.purpletech.com/
> jGuru - Java News and FAQs                 http://www.jguru.com/alex/
> Gamelan - the Original Java site           http://www.gamelan.com/
> Stinky - Art and Angst                     http://www.stinky.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 

Steven Caswell
steven@caswell.name
a.k.a Mungo Knotwise of Michel Delving
"One ring to rule them all, one ring to find them..."



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

Posted by Alex Chaffee / Purple Technology <gu...@stinky.com>.
On Sun, Mar 09, 2003 at 04:05:09PM -0500, Steven Caswell wrote:
> > I think "bisect" is good since it explicitly means "two 
> > parts" rather than "split" which returns many parts.
> 
> Wouldn't "removeFromLast" describe the action more succiently than
> "bisect" or "divide"?

"from" is ambiguous... Which is clearer:

  removeAfterLast("my dog has dog fleas", "dog") -> "my dog has "
  removeBeforeLast("my dog has dog fleas", "dog") -> " fleas"
or
  bisectBeforeLast("my dog has dog fleas", "dog") -> "my dog has "
  bisectAfterLast("my dog has dog fleas", "dog") -> " fleas"

Or is "split" really the right root after all?

(This is the sort of tough naming decision that becomes clear only
after one has used the API in the wild for a while, and (these days)
renamed it a few times with a refactoring tool...  So maybe we should
just pick one and reserve the right to change our mind before the
first release.)

> > * toUnderscoreName, toCamelCaseName
> > 
> I still think these are more functionality than is intended in StringUtils.
> Would it make sense to put them into a StringConvertUtils?

But there are many "conversion" routines already in StringUtils, so
this would create an arbitrary and confusing disjunction (confusing to
those trying to figure out in which class a certain method lies).


-- 
Alex Chaffee                               mailto:alex@jguru.com
Purple Technology - Code and Consulting    http://www.purpletech.com/
jGuru - Java News and FAQs                 http://www.jguru.com/alex/
Gamelan - the Original Java site           http://www.gamelan.com/
Stinky - Art and Angst                     http://www.stinky.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


RE: [lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

Posted by Steven Caswell <st...@caswell.name>.
See below...

> -----Original Message-----
> From: Alex Chaffee / Purple Technology [mailto:guru@stinky.com] 
> Sent: Sunday, March 09, 2003 3:09 PM
> To: Jakarta Commons Developers List
> Subject: Re: [lang] Summarising Purple Was: [lang] Adding 
> Purple to StringUtils
> 
> 
> * abbreviate
>  
> OK!  How about I add this one myself?  I'm a Tomcat 
> committer; whom do I ask to add me to the karma list for 
> commons?  (I think I heard that Tomcat committers don't need 
> a confirmation vote.)
> 
> 
> * integrate truncateNicely and abbreviate
> 
> This I'd have to do research on; probably should wait until
> abbreviate() is done.
> 
> 
> * differentAt, differentText
> 
> I like these names.  Another suggestion is to use 
> "difference" since that describes the return value (and 
> "different" implies it's returning a boolean, like "is 
> different" vs. "get the difference").
> 
> So can I get a +1 on:
> 	public String difference(String s1, String s2)
> 	public int differenceAt(String s1, String s2)
> 

+1, for the reasons enumerated

> 
> * Change chomp to match perl
> 
> I can do this too.
> 
> 
> * Rename current chomp
> 
> I've been getting in the habit of restricting the use of 
> "get" in method names (properties only).  So I prefer a verb 
> like "bisect" or "divide" rather than "getAfterFirst" and such.  
> 
> I think "bisect" is good since it explicitly means "two 
> parts" rather than "split" which returns many parts.

Wouldn't "removeFromLast" describe the action more succiently than "bisect"
or "divide"?

> 
> 
> * Change getPrechomp [aka getAfterFirst or bisectAfter] to 
> not return the separator.
> 
> That sounds fine; how do we handle deprecation warnings for 
> this and for chomp?  (In case people rely on the old behavior.)
> 
> 
> * escapeHtml, unescapeHtml 
> * escapeJava, escapeJavaScript
> * future: escapeSql, escapeXml, unescape*
> 
> Henri suggested to make StringEscapeUtils.java to hold all 
> these.  I like that a lot.  Any more +1s?

+1. I like the separation.

> 
> As for deprecation, the only method that would need to be 
> deprecated is StringUtils.escape.  Since Java escaping is the 
> natural thing you'd expect StringUtils to do, it makes sense 
> to leave it in there as StringUtils.escape.  So I propose 
> leaving that as it is, and instead just making it call 
> StringEscapeUtils.escapeJava.
> 

+1, because it avoids deprecation

> 
> * uncurlQuotes
> 
> There was no vote on this.  It's not escaping, but 
> converting, so I think it belongs in the base StringUtils.  
> Any objections?
> 
> 
> * toUnderscoreName, toCamelCaseName
> 
> This is not escaping, so it doesn't belong in 
> StringEscapeUtils.  I'd be happy to put them in StringUtils...
> 
> ... especially since I just realized that these two methods, 
> in combination with upperCase and lowerCase and and 
> replace(s, "_", " ") and uncapitalise and capitaliseAllWords, 
> can be used to convert between all of
> 
> 	yo mama
> 	Yo Mama
> 	Yo_Mama
> 	yo_mama
> 	YO_MAMA
> 	YoMama
> 	yoMama
> 
> The only question now is how many convenience methods we want 
> to clutter the API with.

I still think these are more functionality than is intended in StringUtils.
Would it make sense to put them into a StringConvertUtils?

> 
> 
> 
> -- 
> Alex Chaffee                               mailto:alex@jguru.com
> Purple Technology - Code and Consulting    http://www.purpletech.com/
> jGuru - Java News and FAQs                 http://www.jguru.com/alex/
> Gamelan - the Original Java site           http://www.gamelan.com/
> Stinky - Art and Angst                     http://www.stinky.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 

Steven Caswell
steven@caswell.name
a.k.a Mungo Knotwise of Michel Delving
"One ring to rule them all, one ring to find them..."




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] Summarising Purple Was: [lang] Adding Purple to StringUtils

Posted by Alex Chaffee / Purple Technology <gu...@stinky.com>.
* abbreviate
 
OK!  How about I add this one myself?  I'm a Tomcat committer; whom do
I ask to add me to the karma list for commons?  (I think I heard that
Tomcat committers don't need a confirmation vote.)


* integrate truncateNicely and abbreviate

This I'd have to do research on; probably should wait until
abbreviate() is done.


* differentAt, differentText

I like these names.  Another suggestion is to use "difference" since
that describes the return value (and "different" implies it's
returning a boolean, like "is different" vs. "get the difference").

So can I get a +1 on:
	public String difference(String s1, String s2)
	public int differenceAt(String s1, String s2)


* Change chomp to match perl

I can do this too.


* Rename current chomp

I've been getting in the habit of restricting the use of "get" in
method names (properties only).  So I prefer a verb like "bisect" or
"divide" rather than "getAfterFirst" and such.  

I think "bisect" is good since it explicitly means "two parts" rather
than "split" which returns many parts.


* Change getPrechomp [aka getAfterFirst or bisectAfter] to not return
the separator.

That sounds fine; how do we handle deprecation warnings for this and
for chomp?  (In case people rely on the old behavior.)


* escapeHtml, unescapeHtml 
* escapeJava, escapeJavaScript
* future: escapeSql, escapeXml, unescape*

Henri suggested to make StringEscapeUtils.java to hold all these.  I
like that a lot.  Any more +1s?

As for deprecation, the only method that would need to be deprecated
is StringUtils.escape.  Since Java escaping is the natural thing you'd
expect StringUtils to do, it makes sense to leave it in there as
StringUtils.escape.  So I propose leaving that as it is, and instead
just making it call StringEscapeUtils.escapeJava.


* uncurlQuotes

There was no vote on this.  It's not escaping, but converting, so I
think it belongs in the base StringUtils.  Any objections?


* toUnderscoreName, toCamelCaseName

This is not escaping, so it doesn't belong in StringEscapeUtils.  I'd
be happy to put them in StringUtils...

... especially since I just realized that these two methods, in
combination with upperCase and lowerCase and and replace(s, "_", " ")
and uncapitalise and capitaliseAllWords, can be used to convert
between all of

	yo mama
	Yo Mama
	Yo_Mama
	yo_mama
	YO_MAMA
	YoMama
	yoMama

The only question now is how many convenience methods we want to
clutter the API with.



-- 
Alex Chaffee                               mailto:alex@jguru.com
Purple Technology - Code and Consulting    http://www.purpletech.com/
jGuru - Java News and FAQs                 http://www.jguru.com/alex/
Gamelan - the Original Java site           http://www.gamelan.com/
Stinky - Art and Angst                     http://www.stinky.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org