You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2009/02/13 01:14:41 UTC

[Proposal] Create a sandbox commons-money component?

One of the items the JDK doesn't have is a Money class (despite having a 
Currency class). I'm raising the question of whether others here would 
be interested in creating a new component (or possibly adding it to a 
Java 5 version of commons-lang).

I have recently coded a Money class with full tests, which I have 
considered releasing as a Joda-Money component. But I don't really have 
the time to put into this with the JSR-310 work. If there are others at 
commons that want to take what I've done and breath life into it to get 
it released perhaps that might be the best way?

I don't consider what I have done to be complete BTW. It is a basic 
Money class, but I was planning on adding BigMoney, formatting and 
parsing too - if I had enough time.

One key scope point, I see this as just being to provide the value 
objects and formatting. All the myriad of financial calculations 
shouldn't be part of the basic commons-money, thus it would be a very 
small component.

To reiterate, I don't really have time to lead this or release it, so 
I'm just testing the water to see if it piques anyone's interest.

Stephen



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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Corey Scott <co...@gmail.com>.
Stephen,

I have to say my interest is peaked. I'm interested to see what you have 
in mind for this.

-Corey


Stephen Colebourne wrote:
> One of the items the JDK doesn't have is a Money class (despite having 
> a Currency class). I'm raising the question of whether others here 
> would be interested in creating a new component (or possibly adding it 
> to a Java 5 version of commons-lang).
>
> I have recently coded a Money class with full tests, which I have 
> considered releasing as a Joda-Money component. But I don't really 
> have the time to put into this with the JSR-310 work. If there are 
> others at commons that want to take what I've done and breath life 
> into it to get it released perhaps that might be the best way?
>
> I don't consider what I have done to be complete BTW. It is a basic 
> Money class, but I was planning on adding BigMoney, formatting and 
> parsing too - if I had enough time.
>
> One key scope point, I see this as just being to provide the value 
> objects and formatting. All the myriad of financial calculations 
> shouldn't be part of the basic commons-money, thus it would be a very 
> small component.
>
> To reiterate, I don't really have time to lead this or release it, so 
> I'm just testing the water to see if it piques anyone's interest.
>
> Stephen
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Ralph Goers wrote:
>> I've checked the commons-money code into the sandbox. I don't have any 
>> time to write more code there ATM, but more needs doing before any 
>> release. If anyone likes the code, and the idea behind BigMoney, or 
>> formatting/parsing then please go ahead and make some changes. Thats 
>> what the sandbox is for.
>> Stephen
> 
> I was very surprised not to see a method like ofMinor(Locale locale, 
> long amountMinor) or even ofMinor(long amountMinor). The currency should 
> be derivable from the locale and when none is specified the default 
> should be used.

Adding Locale factory variants would be OK I think.

I'm not a huge fan of using the default locale - it adds a hidden 
dependency that you don't see in testing.

Stephen

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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Julius Davies wrote:
> Why even bother with the "long" version?  I think Money should use
> BigDecimal (or BigInteger... whatever) under the hood exclusively.
> 
> BigDecimal/BigInteger already have special optimizations for when they
> can fit themselves in a long.
> 
> (I would more lean towards BigInteger under the hood, and using it to
> represent 4 decimal points.)

The difference represents different use cases.

Money allows you to represent $19.95, $0.01, $10,000,000,000,000.00 and 
so on. The key point is that it is constrained to have two decimal 
places (or more strictly, the correct number of dp for the currency).

BigMoney (TBD) would allow you to have any value to any size and precision.

Your proposal to always use 4dp would be of no use to a business that 
needs 5dp or more. (I should also note that performance isn't a critical 
factor in choosing a long, it just makes more sense for that use case)

The difference is driven by my take on use cases that many businesses 
would be happy with a simple class and never to have to think about 
fractions. Whereas others (typically bigger) will have strict, and 
differeing, rules on what is valid.

Another use case would be storing values using Money, manipulate and 
calculate using BigMoney and then convert back to Money again for storage.

Stephen

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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Julius Davies <ju...@gmail.com>.
Why even bother with the "long" version?  I think Money should use
BigDecimal (or BigInteger... whatever) under the hood exclusively.

BigDecimal/BigInteger already have special optimizations for when they
can fit themselves in a long.

(I would more lean towards BigInteger under the hood, and using it to
represent 4 decimal points.)



-- 
yours,

Julius Davies
250-592-2284 (Home)
250-893-4579 (Mobile)
http://juliusdavies.ca/

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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Ralph Goers <ra...@dslextreme.com>.
On Feb 13, 2009, at 4:57 PM, Stephen Colebourne wrote:

> I've checked the commons-money code into the sandbox. I don't have  
> any time to write more code there ATM, but more needs doing before  
> any release. If anyone likes the code, and the idea behind BigMoney,  
> or formatting/parsing then please go ahead and make some changes.  
> Thats what the sandbox is for.
> Stephen
>

I was very surprised not to see a method like ofMinor(Locale locale,  
long amountMinor) or even ofMinor(long amountMinor). The currency  
should be derivable from the locale and when none is specified the  
default should be used.

Ralph


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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
I've checked the commons-money code into the sandbox. I don't have any 
time to write more code there ATM, but more needs doing before any 
release. If anyone likes the code, and the idea behind BigMoney, or 
formatting/parsing then please go ahead and make some changes. Thats 
what the sandbox is for.
Stephen

Stephen Colebourne wrote:
> My view is to keep it simple. I'm not sure that general I18N code has 
> much in common with Money.
> 
> As there seems to be some interest I'll try and check in to the sandbox.
> 
> Stephen
> 
> 
> Ralph Goers wrote:
>> Is "Money" going to support I18N? I would think it would be more 
>> appropriate to include in a collection of I18N stuff than in with lang 
>> or by itself.  I'm not too enamored with the current implementations 
>> of ResourceBundles. Struts MessageResource (which they seem to have 
>> dropped in struts2) and Spring MessageSource seem to be a little 
>> better, but I need an I18N system which has a lot of the capabilities 
>> that Cocoon's has (multiple locations and recursive replacement) - 
>> without needing the rest of Cocoon.
>>
>> Ralph
>>
>>
>> On Feb 12, 2009, at 4:14 PM, Stephen Colebourne wrote:
>>
>>> One of the items the JDK doesn't have is a Money class (despite 
>>> having a Currency class). I'm raising the question of whether others 
>>> here would be interested in creating a new component (or possibly 
>>> adding it to a Java 5 version of commons-lang).
>>>
>>> I have recently coded a Money class with full tests, which I have 
>>> considered releasing as a Joda-Money component. But I don't really 
>>> have the time to put into this with the JSR-310 work. If there are 
>>> others at commons that want to take what I've done and breath life 
>>> into it to get it released perhaps that might be the best way?
>>>
>>> I don't consider what I have done to be complete BTW. It is a basic 
>>> Money class, but I was planning on adding BigMoney, formatting and 
>>> parsing too - if I had enough time.
>>>
>>> One key scope point, I see this as just being to provide the value 
>>> objects and formatting. All the myriad of financial calculations 
>>> shouldn't be part of the basic commons-money, thus it would be a very 
>>> small component.
>>>
>>> To reiterate, I don't really have time to lead this or release it, so 
>>> I'm just testing the water to see if it piques anyone's interest.
>>>
>>> Stephen
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 
> 

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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
My view is to keep it simple. I'm not sure that general I18N code has 
much in common with Money.

As there seems to be some interest I'll try and check in to the sandbox.

Stephen


Ralph Goers wrote:
> Is "Money" going to support I18N? I would think it would be more 
> appropriate to include in a collection of I18N stuff than in with lang 
> or by itself.  I'm not too enamored with the current implementations of 
> ResourceBundles. Struts MessageResource (which they seem to have dropped 
> in struts2) and Spring MessageSource seem to be a little better, but I 
> need an I18N system which has a lot of the capabilities that Cocoon's 
> has (multiple locations and recursive replacement) - without needing the 
> rest of Cocoon.
> 
> Ralph
> 
> 
> On Feb 12, 2009, at 4:14 PM, Stephen Colebourne wrote:
> 
>> One of the items the JDK doesn't have is a Money class (despite having 
>> a Currency class). I'm raising the question of whether others here 
>> would be interested in creating a new component (or possibly adding it 
>> to a Java 5 version of commons-lang).
>>
>> I have recently coded a Money class with full tests, which I have 
>> considered releasing as a Joda-Money component. But I don't really 
>> have the time to put into this with the JSR-310 work. If there are 
>> others at commons that want to take what I've done and breath life 
>> into it to get it released perhaps that might be the best way?
>>
>> I don't consider what I have done to be complete BTW. It is a basic 
>> Money class, but I was planning on adding BigMoney, formatting and 
>> parsing too - if I had enough time.
>>
>> One key scope point, I see this as just being to provide the value 
>> objects and formatting. All the myriad of financial calculations 
>> shouldn't be part of the basic commons-money, thus it would be a very 
>> small component.
>>
>> To reiterate, I don't really have time to lead this or release it, so 
>> I'm just testing the water to see if it piques anyone's interest.
>>
>> Stephen
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 
> 

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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Ralph Goers <ra...@dslextreme.com>.
Is "Money" going to support I18N? I would think it would be more  
appropriate to include in a collection of I18N stuff than in with lang  
or by itself.  I'm not too enamored with the current implementations  
of ResourceBundles. Struts MessageResource (which they seem to have  
dropped in struts2) and Spring MessageSource seem to be a little  
better, but I need an I18N system which has a lot of the capabilities  
that Cocoon's has (multiple locations and recursive replacement) -  
without needing the rest of Cocoon.

Ralph


On Feb 12, 2009, at 4:14 PM, Stephen Colebourne wrote:

> One of the items the JDK doesn't have is a Money class (despite  
> having a Currency class). I'm raising the question of whether others  
> here would be interested in creating a new component (or possibly  
> adding it to a Java 5 version of commons-lang).
>
> I have recently coded a Money class with full tests, which I have  
> considered releasing as a Joda-Money component. But I don't really  
> have the time to put into this with the JSR-310 work. If there are  
> others at commons that want to take what I've done and breath life  
> into it to get it released perhaps that might be the best way?
>
> I don't consider what I have done to be complete BTW. It is a basic  
> Money class, but I was planning on adding BigMoney, formatting and  
> parsing too - if I had enough time.
>
> One key scope point, I see this as just being to provide the value  
> objects and formatting. All the myriad of financial calculations  
> shouldn't be part of the basic commons-money, thus it would be a  
> very small component.
>
> To reiterate, I don't really have time to lead this or release it,  
> so I'm just testing the water to see if it piques anyone's interest.
>
> Stephen
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>


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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Bill Barker <wb...@wilshire.com>.
"Stephen Colebourne" <sc...@btopenworld.com> wrote in message 
news:4994BB71.9070808@btopenworld.com...
> One of the items the JDK doesn't have is a Money class (despite having a 
> Currency class). I'm raising the question of whether others here would be 
> interested in creating a new component (or possibly adding it to a Java 5 
> version of commons-lang).
>
> I have recently coded a Money class with full tests, which I have 
> considered releasing as a Joda-Money component. But I don't really have 
> the time to put into this with the JSR-310 work. If there are others at 
> commons that want to take what I've done and breath life into it to get it 
> released perhaps that might be the best way?
>
> I don't consider what I have done to be complete BTW. It is a basic Money 
> class, but I was planning on adding BigMoney, formatting and parsing too - 
> if I had enough time.
>
> One key scope point, I see this as just being to provide the value objects 
> and formatting. All the myriad of financial calculations shouldn't be part 
> of the basic commons-money, thus it would be a very small component.
>

I'm definately interested even in just the basic version.  But would put in 
time to work on the finacial calculations as well if the project wanted to 
go there.

> To reiterate, I don't really have time to lead this or release it, so I'm 
> just testing the water to see if it piques anyone's interest.
>
> Stephen 




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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Paul Benedict <pb...@apache.org>.
I am all for commons money. It sounds like a great economic stimulus plan.

If you'd like to share some with me, please write a check to my home address.

Paul

On Thu, Feb 12, 2009 at 10:49 PM, Henri Yandell <fl...@gmail.com> wrote:
> Sounds fun, +1. Definitely fits my "I'll join in" interest area.
>
> On Thu, Feb 12, 2009 at 4:14 PM, Stephen Colebourne
> <sc...@btopenworld.com> wrote:
>> One of the items the JDK doesn't have is a Money class (despite having a
>> Currency class). I'm raising the question of whether others here would be
>> interested in creating a new component (or possibly adding it to a Java 5
>> version of commons-lang).
>>
>> I have recently coded a Money class with full tests, which I have considered
>> releasing as a Joda-Money component. But I don't really have the time to put
>> into this with the JSR-310 work. If there are others at commons that want to
>> take what I've done and breath life into it to get it released perhaps that
>> might be the best way?
>>
>> I don't consider what I have done to be complete BTW. It is a basic Money
>> class, but I was planning on adding BigMoney, formatting and parsing too -
>> if I had enough time.
>>
>> One key scope point, I see this as just being to provide the value objects
>> and formatting. All the myriad of financial calculations shouldn't be part
>> of the basic commons-money, thus it would be a very small component.
>>
>> To reiterate, I don't really have time to lead this or release it, so I'm
>> just testing the water to see if it piques anyone's interest.
>>
>> Stephen
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Re: [Proposal] Create a sandbox commons-money component?

Posted by Henri Yandell <fl...@gmail.com>.
Sounds fun, +1. Definitely fits my "I'll join in" interest area.

On Thu, Feb 12, 2009 at 4:14 PM, Stephen Colebourne
<sc...@btopenworld.com> wrote:
> One of the items the JDK doesn't have is a Money class (despite having a
> Currency class). I'm raising the question of whether others here would be
> interested in creating a new component (or possibly adding it to a Java 5
> version of commons-lang).
>
> I have recently coded a Money class with full tests, which I have considered
> releasing as a Joda-Money component. But I don't really have the time to put
> into this with the JSR-310 work. If there are others at commons that want to
> take what I've done and breath life into it to get it released perhaps that
> might be the best way?
>
> I don't consider what I have done to be complete BTW. It is a basic Money
> class, but I was planning on adding BigMoney, formatting and parsing too -
> if I had enough time.
>
> One key scope point, I see this as just being to provide the value objects
> and formatting. All the myriad of financial calculations shouldn't be part
> of the basic commons-money, thus it would be a very small component.
>
> To reiterate, I don't really have time to lead this or release it, so I'm
> just testing the water to see if it piques anyone's interest.
>
> Stephen
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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