Re: [5/5] commons-numbers git commit: Add maven module for fractions package from commons-math Resolves pull request #4

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [5/5] commons-numbers git commit: Add maven module for fractions package from commons-math Resolves pull request #4

Gilles Sadowski
Hi Ray.

On Sat, 28 Jan 2017 12:44:27 -0000, [hidden email] wrote:
> Add maven module for fractions package from commons-math
> Resolves pull request #4

Whenever possible, we aim at small commits (unless they are all of
the same kind, and it is obvious what is being done repeatedly).

In particular, independent codes should be added incrementally, to
allow for easier review.
For example, modifications to "pom.xml", addition of "ArithmeticUtils",
"Fraction" and "BigFraction", etc.

Please note that you worked on an outdated branch.
[Please read the guidelines in "doc/development".]
Can you fix that (using "rebase" I guess) before we discuss the
contents of the commit?

Also to allow easy review: the commit message should refer to the
JIRA issue identifier).


Thanks,
Gilles


> Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
> Commit:
>
> http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/763ec4fe
> Tree:
> http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/763ec4fe
> Diff:
> http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/763ec4fe
>
> Branch: refs/heads/multimodule
> Commit: 763ec4fea595ea53792bf2a7d3dd08dedc567909
> Parents: 69d3b62 aaef6f7
> Author: Ray DeCampo <[hidden email]>
> Authored: Sat Jan 28 07:41:48 2017 -0500
> Committer: Ray DeCampo <[hidden email]>
> Committed: Sat Jan 28 07:41:48 2017 -0500
>
>
> ----------------------------------------------------------------------
>  commons-numbers-complex/pom.xml                 |    1 -
>  commons-numbers-core/pom.xml                    |   15 +
>  .../commons/numbers/core/ArithmeticUtils.java   |  772 +++++++++++
>  .../core/NumbersArithmeticException.java        |   54 +
>  .../numbers/core/ArithmeticUtilsTest.java       |  782 ++++++++++++
>  commons-numbers-fraction/LICENSE.txt            |  201 +++
>  commons-numbers-fraction/NOTICE.txt             |    6 +
>  commons-numbers-fraction/README.md              |   98 ++
>  commons-numbers-fraction/pom.xml                |   58 +
>  .../numbers/fraction/AbstractFormat.java        |  206 +++
>  .../commons/numbers/fraction/BigFraction.java   | 1199
> ++++++++++++++++++
>  .../numbers/fraction/BigFractionField.java      |   83 ++
>  .../numbers/fraction/BigFractionFormat.java     |  283 +++++
>  .../commons/numbers/fraction/Fraction.java      |  664 ++++++++++
>  .../fraction/FractionConversionException.java   |   51 +
>  .../numbers/fraction/FractionException.java     |   44 +
>  .../commons/numbers/fraction/FractionField.java |   82 ++
>  .../numbers/fraction/FractionFormat.java        |  261 ++++
>  .../fraction/FractionOverflowException.java     |   47 +
>  .../fraction/FractionParseException.java        |   38 +
>  .../fraction/ProperBigFractionFormat.java       |  235 ++++
>  .../numbers/fraction/ProperFractionFormat.java  |  227 ++++
>  .../fraction/ZeroDenominatorException.java      |   53 +
>  .../commons/numbers/fraction/package-info.java  |   22 +
>  .../numbers/fraction/BigFractionFieldTest.java  |   43 +
>  .../numbers/fraction/BigFractionFormatTest.java |  330 +++++
>  .../numbers/fraction/BigFractionTest.java       |  635 ++++++++++
>  .../numbers/fraction/FractionFieldTest.java     |   43 +
>  .../numbers/fraction/FractionFormatTest.java    |  349 +++++
>  .../commons/numbers/fraction/FractionTest.java  |  625 +++++++++
>  commons-numbers-quaternion/pom.xml              |    1 -
>  pom.xml                                         |   20 +-
>  32 files changed, 7525 insertions(+), 3 deletions(-)
>
> ----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [5/5] commons-numbers git commit: Add maven module for fractions package from commons-math Resolves pull request #4

Raymond DeCampo
Thanks for the feedback Gilles.

I generally prefer to work in smaller increments so that suits me fine.

Re working on an outdated branch, I'm not sure I completely understand what
you want plus I am not a git expert by any stretch.  Are you suggesting I
back out the changes on the multimodule branch using rebase?  Then
following the guidelines from doc/development create a feature branch and
then chunk the changes up into digestible commits on that branch?

I realized my mistake on not referring to the JIRA issue on the commit
right away (it's always something).



On Sat, Jan 28, 2017 at 8:36 AM, Gilles <[hidden email]>
wrote:

> Hi Ray.
>
> On Sat, 28 Jan 2017 12:44:27 -0000, [hidden email] wrote:
>
>> Add maven module for fractions package from commons-math
>> Resolves pull request #4
>>
>
> Whenever possible, we aim at small commits (unless they are all of
> the same kind, and it is obvious what is being done repeatedly).
>
> In particular, independent codes should be added incrementally, to
> allow for easier review.
> For example, modifications to "pom.xml", addition of "ArithmeticUtils",
> "Fraction" and "BigFraction", etc.
>
> Please note that you worked on an outdated branch.
> [Please read the guidelines in "doc/development".]
> Can you fix that (using "rebase" I guess) before we discuss the
> contents of the commit?
>
> Also to allow easy review: the commit message should refer to the
> JIRA issue identifier).
>
>
> Thanks,
> Gilles
>
>
>
> Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
>> Commit:
>>
>> http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/763ec4fe
>> Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/
>> 763ec4fe
>> Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/
>> 763ec4fe
>>
>> Branch: refs/heads/multimodule
>> Commit: 763ec4fea595ea53792bf2a7d3dd08dedc567909
>> Parents: 69d3b62 aaef6f7
>> Author: Ray DeCampo <[hidden email]>
>> Authored: Sat Jan 28 07:41:48 2017 -0500
>> Committer: Ray DeCampo <[hidden email]>
>> Committed: Sat Jan 28 07:41:48 2017 -0500
>>
>>
>> ----------------------------------------------------------------------
>>  commons-numbers-complex/pom.xml                 |    1 -
>>  commons-numbers-core/pom.xml                    |   15 +
>>  .../commons/numbers/core/ArithmeticUtils.java   |  772 +++++++++++
>>  .../core/NumbersArithmeticException.java        |   54 +
>>  .../numbers/core/ArithmeticUtilsTest.java       |  782 ++++++++++++
>>  commons-numbers-fraction/LICENSE.txt            |  201 +++
>>  commons-numbers-fraction/NOTICE.txt             |    6 +
>>  commons-numbers-fraction/README.md              |   98 ++
>>  commons-numbers-fraction/pom.xml                |   58 +
>>  .../numbers/fraction/AbstractFormat.java        |  206 +++
>>  .../commons/numbers/fraction/BigFraction.java   | 1199
>> ++++++++++++++++++
>>  .../numbers/fraction/BigFractionField.java      |   83 ++
>>  .../numbers/fraction/BigFractionFormat.java     |  283 +++++
>>  .../commons/numbers/fraction/Fraction.java      |  664 ++++++++++
>>  .../fraction/FractionConversionException.java   |   51 +
>>  .../numbers/fraction/FractionException.java     |   44 +
>>  .../commons/numbers/fraction/FractionField.java |   82 ++
>>  .../numbers/fraction/FractionFormat.java        |  261 ++++
>>  .../fraction/FractionOverflowException.java     |   47 +
>>  .../fraction/FractionParseException.java        |   38 +
>>  .../fraction/ProperBigFractionFormat.java       |  235 ++++
>>  .../numbers/fraction/ProperFractionFormat.java  |  227 ++++
>>  .../fraction/ZeroDenominatorException.java      |   53 +
>>  .../commons/numbers/fraction/package-info.java  |   22 +
>>  .../numbers/fraction/BigFractionFieldTest.java  |   43 +
>>  .../numbers/fraction/BigFractionFormatTest.java |  330 +++++
>>  .../numbers/fraction/BigFractionTest.java       |  635 ++++++++++
>>  .../numbers/fraction/FractionFieldTest.java     |   43 +
>>  .../numbers/fraction/FractionFormatTest.java    |  349 +++++
>>  .../commons/numbers/fraction/FractionTest.java  |  625 +++++++++
>>  commons-numbers-quaternion/pom.xml              |    1 -
>>  pom.xml                                         |   20 +-
>>  32 files changed, 7525 insertions(+), 3 deletions(-)
>>
>> ----------------------------------------------------------------------
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

[Numbers] Further work on NUMBERS-6 (Was: [5/5] Add maven module for fractions [...])

Gilles Sadowski
On Sat, 28 Jan 2017 09:00:52 -0500, Raymond DeCampo wrote:
> Thanks for the feedback Gilles.

Thanks for helping with the project!

> I generally prefer to work in smaller increments so that suits me
> fine.
>
> Re working on an outdated branch, I'm not sure I completely
> understand what
> you want plus I am not a git expert by any stretch.

I'm not either.
Hence I prefer to keep it simple and avoid potential conflicts by
creating
a branch from master HEAD and do as many "git rebase" as necessary to
keep
in sync with master while working on "feature X".

> Are you suggesting I
> back out the changes on the multimodule branch using rebase?

Not sure that's the easiest way.

I've just created a
   fraction__NUMBERS-6
branch based on your work, and did
   git rebase master
on it.

Let's now work on that one (and delete "multimodule") until we are
happy
about its contents.

> Then
> following the guidelines from doc/development create a feature branch
> and
> then chunk the changes up into digestible commits on that branch?

Not worth the time, now.
I mentioned it for future work; when commits are large, people tend to
not want to review them. ;-)

> I realized my mistake on not referring to the JIRA issue on the
> commit
> right away (it's always something).

I fixed that in "fraction__NUMBERS-6", with
   git commit --amend

Now, for the contents of the "fraction" module.

(1)
My main current concern is the formatting-related classes; as for
"complex", I think that
  1. formatting (and I/O) is out of scope, and
  2. the implementation were problematic in CM already.
Hence, I'd prefer to drop support altogether.[1]

(2)
Another concern is what to do with the "XxxField" classes.

(3)
All "@since" tags must be removed.

(4)
Right now, I think that we should not advertize specific exceptions.
I.e. they should have at most "package" visibility, or maybe even
better: private inner class.
The Javadoc "@throws" should mention the JDK's parent class.
This is a departure from what was done in CM, where the design was
trying to satisfy mixed requirements, never shown (IMO to be really
necessary for a supposedly "low-level" library).
My stance is that whenever an exception is thrown from an application,
there is a programming error that must be solved by looking at the
code (to find the faulty call or bug in the library).

Regards,
Gilles

[1] There could be a "math-module" in "Commons Text" that would do
     such things, with the support of more advanced text manipulation
     classes.

>
>
>
> On Sat, Jan 28, 2017 at 8:36 AM, Gilles
> <[hidden email]>
> wrote:
>
>> Hi Ray.
>>
>> On Sat, 28 Jan 2017 12:44:27 -0000, [hidden email] wrote:
>>
>>> Add maven module for fractions package from commons-math
>>> Resolves pull request #4
>>>
>>
>> Whenever possible, we aim at small commits (unless they are all of
>> the same kind, and it is obvious what is being done repeatedly).
>>
>> In particular, independent codes should be added incrementally, to
>> allow for easier review.
>> For example, modifications to "pom.xml", addition of
>> "ArithmeticUtils",
>> "Fraction" and "BigFraction", etc.
>>
>> Please note that you worked on an outdated branch.
>> [Please read the guidelines in "doc/development".]
>> Can you fix that (using "rebase" I guess) before we discuss the
>> contents of the commit?
>>
>> Also to allow easy review: the commit message should refer to the
>> JIRA issue identifier).
>>
>>
>> Thanks,
>> Gilles
>>
>>
>>
>>> [...]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Further work on NUMBERS-6 (Was: [5/5] Add maven module for fractions [...])

Raymond DeCampo
On Sat, Jan 28, 2017 at 10:48 AM, Gilles <[hidden email]>
wrote:

> On Sat, 28 Jan 2017 09:00:52 -0500, Raymond DeCampo wrote:
>
>> Thanks for the feedback Gilles.
>>
>
> Thanks for helping with the project!
>
> I generally prefer to work in smaller increments so that suits me fine.
>>
>> Re working on an outdated branch, I'm not sure I completely understand
>> what
>> you want plus I am not a git expert by any stretch.
>>
>
> I'm not either.
> Hence I prefer to keep it simple and avoid potential conflicts by creating
> a branch from master HEAD and do as many "git rebase" as necessary to keep
> in sync with master while working on "feature X".
>
> Are you suggesting I
>> back out the changes on the multimodule branch using rebase?
>>
>
> Not sure that's the easiest way.
>
> I've just created a
>   fraction__NUMBERS-6
> branch based on your work, and did
>   git rebase master
> on it.
>
> Let's now work on that one (and delete "multimodule") until we are happy
> about its contents.
>

Sounds like a reasonable plan.


>
> Then
>> following the guidelines from doc/development create a feature branch and
>> then chunk the changes up into digestible commits on that branch?
>>
>
> Not worth the time, now.
> I mentioned it for future work; when commits are large, people tend to
> not want to review them. ;-)
>
> I realized my mistake on not referring to the JIRA issue on the commit
>> right away (it's always something).
>>
>
> I fixed that in "fraction__NUMBERS-6", with
>   git commit --amend
>
> Now, for the contents of the "fraction" module.
>
> (1)
> My main current concern is the formatting-related classes; as for
> "complex", I think that
>  1. formatting (and I/O) is out of scope, and
>  2. the implementation were problematic in CM already.
> Hence, I'd prefer to drop support altogether.[1]
>
>
I see your point of view, but allow me to play devil's advocate.  It seems
natural to create the formatter for a new object, in particular a number
type, close to the type itself.  Making new objects and expecting another
project to implement the formatting seems like what economists call an
externality.  I suppose it really depends how everyone maintaining text
would feel about it.  I am somewhat concerned about how the release cycle
would work, in particular for the initial released, where text would have
to wait for a release of numbers before including the formatting and then
users would not have formatting until the next release of text.

That said if the people maintaining text agree I have no objection.


> (2)
> Another concern is what to do with the "XxxField" classes.
>

Do we have any idea if the user base uses these classes?  It's no problem
to continue to maintain them (at least from my point of view) but I am
having difficulty imagining the use case.


>
> (3)
> All "@since" tags must be removed.
>
> (4)
> Right now, I think that we should not advertize specific exceptions.
> I.e. they should have at most "package" visibility, or maybe even
> better: private inner class.
> The Javadoc "@throws" should mention the JDK's parent class.
> This is a departure from what was done in CM, where the design was
> trying to satisfy mixed requirements, never shown (IMO to be really
> necessary for a supposedly "low-level" library).
>

That suits me fine.


> My stance is that whenever an exception is thrown from an application,
> there is a programming error that must be solved by looking at the
> code (to find the faulty call or bug in the library).
>
Regards,

> Gilles
>
> [1] There could be a "math-module" in "Commons Text" that would do
>     such things, with the support of more advanced text manipulation
>     classes.
>
>
>>
>>
>> On Sat, Jan 28, 2017 at 8:36 AM, Gilles <[hidden email]>
>> wrote:
>>
>> Hi Ray.
>>>
>>> On Sat, 28 Jan 2017 12:44:27 -0000, [hidden email] wrote:
>>>
>>> Add maven module for fractions package from commons-math
>>>> Resolves pull request #4
>>>>
>>>>
>>> Whenever possible, we aim at small commits (unless they are all of
>>> the same kind, and it is obvious what is being done repeatedly).
>>>
>>> In particular, independent codes should be added incrementally, to
>>> allow for easier review.
>>> For example, modifications to "pom.xml", addition of "ArithmeticUtils",
>>> "Fraction" and "BigFraction", etc.
>>>
>>> Please note that you worked on an outdated branch.
>>> [Please read the guidelines in "doc/development".]
>>> Can you fix that (using "rebase" I guess) before we discuss the
>>> contents of the commit?
>>>
>>> Also to allow easy review: the commit message should refer to the
>>> JIRA issue identifier).
>>>
>>>
>>> Thanks,
>>> Gilles
>>>
>>>
>>>
>>> [...]
>>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Further work on NUMBERS-6

Gilles Sadowski
Hi.

On Sat, 28 Jan 2017 14:38:21 -0500, Raymond DeCampo wrote:

>> [...]
>>
>> Now, for the contents of the "fraction" module.
>>
>> (1)
>> My main current concern is the formatting-related classes; as for
>> "complex", I think that
>>  1. formatting (and I/O) is out of scope, and
>>  2. the implementation were problematic in CM already.
>> Hence, I'd prefer to drop support altogether.[1]
>>
>>
> I see your point of view, but allow me to play devil's advocate.  It
> seems
> natural to create the formatter for a new object, in particular a
> number
> type, close to the type itself.  Making new objects and expecting
> another
> project to implement the formatting seems like what economists call
> an
> externality.  I suppose it really depends how everyone maintaining
> text
> would feel about it.  I am somewhat concerned about how the release
> cycle
> would work, in particular for the initial released, where text would
> have
> to wait for a release of numbers before including the formatting and
> then
> users would not have formatting until the next release of text.
>
> That said if the people maintaining text agree I have no objection.

[Text] is also a new component. It is not unthinkable that its scope
can encompass flexible formatting of such things as "fractions".
As suggested, someone having a clear idea of what would be the use
cases for formatting fraction, complex, and the likes, can create a
new "commons-text-math-formatting" module (that would depend on the
necessary modules from [Numbers]).
 From my experience with them, the formatting class from [Math] are
not worth keeping.
A lot of other codes should IMHO be given higher priority.

My point is that, generally, people using "fraction" can do with the
constructors (to input data) and the accessors (to read result).
Moreover, developers of "fraction" usually would not want to spend
inordinate amounts of time to satisfy new formatting requests (that
tend to translate into hundreds of lines of code, cf. CM).

The formatting code itself is not part of the concept, and so IMO
effectively out of scope.
There is no more sense to output "ugly" ASCII than there would be
to generate any other output formats that would be more suited to
represent mathematical concept (e.g. LaTeX).

For logging and debugging purpose, "toString" should be quite fine.

Regards,
Gilles

>
>> (2)
>> Another concern is what to do with the "XxxField" classes.
>>
>
> Do we have any idea if the user base uses these classes?  It's no
> problem
> to continue to maintain them (at least from my point of view) but I
> am
> having difficulty imagining the use case.
>
>
>>
>> (3)
>> All "@since" tags must be removed.
>>
>> (4)
>> Right now, I think that we should not advertize specific exceptions.
>> I.e. they should have at most "package" visibility, or maybe even
>> better: private inner class.
>> The Javadoc "@throws" should mention the JDK's parent class.
>> This is a departure from what was done in CM, where the design was
>> trying to satisfy mixed requirements, never shown (IMO to be really
>> necessary for a supposedly "low-level" library).
>>
>
> That suits me fine.
>
>
>> My stance is that whenever an exception is thrown from an
>> application,
>> there is a programming error that must be solved by looking at the
>> code (to find the faulty call or bug in the library).
>>
> Regards,
>> Gilles
>>
>> [1] There could be a "math-module" in "Commons Text" that would do
>>     such things, with the support of more advanced text manipulation
>>     classes.
>>
>>
>>>
>>>
>>> On Sat, Jan 28, 2017 at 8:36 AM, Gilles
>>> <[hidden email]>
>>> wrote:
>>>
>>> Hi Ray.
>>>>
>>>> On Sat, 28 Jan 2017 12:44:27 -0000, [hidden email] wrote:
>>>>
>>>> Add maven module for fractions package from commons-math
>>>>> Resolves pull request #4
>>>>>
>>>>>
>>>> Whenever possible, we aim at small commits (unless they are all of
>>>> the same kind, and it is obvious what is being done repeatedly).
>>>>
>>>> In particular, independent codes should be added incrementally, to
>>>> allow for easier review.
>>>> For example, modifications to "pom.xml", addition of
>>>> "ArithmeticUtils",
>>>> "Fraction" and "BigFraction", etc.
>>>>
>>>> Please note that you worked on an outdated branch.
>>>> [Please read the guidelines in "doc/development".]
>>>> Can you fix that (using "rebase" I guess) before we discuss the
>>>> contents of the commit?
>>>>
>>>> Also to allow easy review: the commit message should refer to the
>>>> JIRA issue identifier).
>>>>
>>>>
>>>> Thanks,
>>>> Gilles
>>>>
>>>>
>>>>
>>>> [...]
>>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Further work on NUMBERS-6

Raymond DeCampo
On Sat, Jan 28, 2017 at 7:00 PM, Gilles <[hidden email]>
wrote:

> Hi.
>
> On Sat, 28 Jan 2017 14:38:21 -0500, Raymond DeCampo wrote:
>
>> [...]
>>>
>>> Now, for the contents of the "fraction" module.
>>>
>>> (1)
>>> My main current concern is the formatting-related classes; as for
>>> "complex", I think that
>>>  1. formatting (and I/O) is out of scope, and
>>>  2. the implementation were problematic in CM already.
>>> Hence, I'd prefer to drop support altogether.[1]
>>>
>>>
>>> I see your point of view, but allow me to play devil's advocate.  It
>> seems
>> natural to create the formatter for a new object, in particular a number
>> type, close to the type itself.  Making new objects and expecting another
>> project to implement the formatting seems like what economists call an
>> externality.  I suppose it really depends how everyone maintaining text
>> would feel about it.  I am somewhat concerned about how the release cycle
>> would work, in particular for the initial released, where text would have
>> to wait for a release of numbers before including the formatting and then
>> users would not have formatting until the next release of text.
>>
>> That said if the people maintaining text agree I have no objection.
>>
>
> [Text] is also a new component. It is not unthinkable that its scope
> can encompass flexible formatting of such things as "fractions".
>

At the risk of raising a sore subject, wasn't the expectations of third
parties that someone else maintain code for them part of the impetus for
the current effort?  So shouldn't we get buy-in from the commons-text team
before we make a decision?


> As suggested, someone having a clear idea of what would be the use
> cases for formatting fraction, complex, and the likes, can create a
> new "commons-text-math-formatting" module (that would depend on the
> necessary modules from [Numbers]).
> From my experience with them, the formatting class from [Math] are
> not worth keeping.
> A lot of other codes should IMHO be given higher priority.


> My point is that, generally, people using "fraction" can do with the
> constructors (to input data) and the accessors (to read result).
> Moreover, developers of "fraction" usually would not want to spend
> inordinate amounts of time to satisfy new formatting requests (that
> tend to translate into hundreds of lines of code, cf. CM).
>

The existence of some formats shouldn't result in an obligation to support
whatever formats are requested.


>
> The formatting code itself is not part of the concept, and so IMO
> effectively out of scope.
> There is no more sense to output "ugly" ASCII than there would be
> to generate any other output formats that would be more suited to
> represent mathematical concept (e.g. LaTeX).
>
> For logging and debugging purpose, "toString" should be quite fine.
>

I imagine that the greater value is in the parsing portion of the format
classes, not the output portion.

Thanks,
Ray


>
> Regards,
> Gilles
>
>
>> (2)
>>> Another concern is what to do with the "XxxField" classes.
>>>
>>>
>> Do we have any idea if the user base uses these classes?  It's no problem
>> to continue to maintain them (at least from my point of view) but I am
>> having difficulty imagining the use case.
>>
>>
>>
>>> (3)
>>> All "@since" tags must be removed.
>>>
>>> (4)
>>> Right now, I think that we should not advertize specific exceptions.
>>> I.e. they should have at most "package" visibility, or maybe even
>>> better: private inner class.
>>> The Javadoc "@throws" should mention the JDK's parent class.
>>> This is a departure from what was done in CM, where the design was
>>> trying to satisfy mixed requirements, never shown (IMO to be really
>>> necessary for a supposedly "low-level" library).
>>>
>>>
>> That suits me fine.
>>
>>
>> My stance is that whenever an exception is thrown from an application,
>>> there is a programming error that must be solved by looking at the
>>> code (to find the faulty call or bug in the library).
>>>
>>> Regards,
>>
>>> Gilles
>>>
>>> [1] There could be a "math-module" in "Commons Text" that would do
>>>     such things, with the support of more advanced text manipulation
>>>     classes.
>>>
>>>
>>>
>>>>
>>>> On Sat, Jan 28, 2017 at 8:36 AM, Gilles <[hidden email]>
>>>> wrote:
>>>>
>>>> Hi Ray.
>>>>
>>>>>
>>>>> On Sat, 28 Jan 2017 12:44:27 -0000, [hidden email] wrote:
>>>>>
>>>>> Add maven module for fractions package from commons-math
>>>>>
>>>>>> Resolves pull request #4
>>>>>>
>>>>>>
>>>>>> Whenever possible, we aim at small commits (unless they are all of
>>>>> the same kind, and it is obvious what is being done repeatedly).
>>>>>
>>>>> In particular, independent codes should be added incrementally, to
>>>>> allow for easier review.
>>>>> For example, modifications to "pom.xml", addition of "ArithmeticUtils",
>>>>> "Fraction" and "BigFraction", etc.
>>>>>
>>>>> Please note that you worked on an outdated branch.
>>>>> [Please read the guidelines in "doc/development".]
>>>>> Can you fix that (using "rebase" I guess) before we discuss the
>>>>> contents of the commit?
>>>>>
>>>>> Also to allow easy review: the commit message should refer to the
>>>>> JIRA issue identifier).
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Gilles
>>>>>
>>>>>
>>>>>
>>>>> [...]
>>>>>
>>>>>>
>>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes (Was: Further work on NUMBERS-6)

Gilles Sadowski
On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:

> On Sat, Jan 28, 2017 at 7:00 PM, Gilles
> <[hidden email]>
> wrote:
>
>> Hi.
>>
>> On Sat, 28 Jan 2017 14:38:21 -0500, Raymond DeCampo wrote:
>>
>>> [...]
>>>>
>>>> Now, for the contents of the "fraction" module.
>>>>
>>>> (1)
>>>> My main current concern is the formatting-related classes; as for
>>>> "complex", I think that
>>>>  1. formatting (and I/O) is out of scope, and
>>>>  2. the implementation were problematic in CM already.
>>>> Hence, I'd prefer to drop support altogether.[1]
>>>>
>>>>
>>>> I see your point of view, but allow me to play devil's advocate.  
>>>> It
>>> seems
>>> natural to create the formatter for a new object, in particular a
>>> number
>>> type, close to the type itself.  Making new objects and expecting
>>> another
>>> project to implement the formatting seems like what economists call
>>> an
>>> externality.  I suppose it really depends how everyone maintaining
>>> text
>>> would feel about it.  I am somewhat concerned about how the release
>>> cycle
>>> would work, in particular for the initial released, where text
>>> would have
>>> to wait for a release of numbers before including the formatting
>>> and then
>>> users would not have formatting until the next release of text.
>>>
>>> That said if the people maintaining text agree I have no objection.
>>>
>>
>> [Text] is also a new component. It is not unthinkable that its scope
>> can encompass flexible formatting of such things as "fractions".
>>
>
> At the risk of raising a sore subject, wasn't the expectations of
> third
> parties that someone else maintain code for them part of the impetus
> for
> the current effort?

I'm not sure I understand what you wrote here.

> So shouldn't we get buy-in from the commons-text team
> before we make a decision?

My proposal does not imply that someone else should implement
the code.

For example, if you feel confident that the input parsing and
output formatting classes are useful and well implemented, you
can start a discussion on this ML (with subject prefix [Text]),
to inquire about objections to moving them to [Text].
It seems that it was informally agreed that [Text] is a somewhat
higher level component, i.e. that it can have runtime dependencies.

>> As suggested, someone having a clear idea of what would be the use
>> cases for formatting fraction, complex, and the likes, can create a
>> new "commons-text-math-formatting" module (that would depend on the
>> necessary modules from [Numbers]).
>> From my experience with them, the formatting class from [Math] are
>> not worth keeping.
>> A lot of other codes should IMHO be given higher priority.
>
>
>> My point is that, generally, people using "fraction" can do with the
>> constructors (to input data) and the accessors (to read result).
>> Moreover, developers of "fraction" usually would not want to spend
>> inordinate amounts of time to satisfy new formatting requests (that
>> tend to translate into hundreds of lines of code, cf. CM).
>>
>
> The existence of some formats shouldn't result in an obligation to
> support
> whatever formats are requested.

Certainly.
But it is easier to justify as "out of scope", rather than "we don't
care about format X".
Then if someone comes up with a good library that can handle the
"Commons Numbers" types, our incomplete code will become obsolete,
and any work put in it will have been useless. The question is:
Are there _currently_ any use-cases for it?

If there aren't, please let's not rush to add it to the new component.

>>
>> The formatting code itself is not part of the concept, and so IMO
>> effectively out of scope.
>> There is no more sense to output "ugly" ASCII than there would be
>> to generate any other output formats that would be more suited to
>> represent mathematical concept (e.g. LaTeX).
>>
>> For logging and debugging purpose, "toString" should be quite fine.
>>
>
> I imagine that the greater value is in the parsing portion of the
> format
> classes, not the output portion.

I do not have enough imagination. ;-)

Regards,
Gilles



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes (Was: Further work on NUMBERS-6)

Raymond DeCampo
On Sun, Jan 29, 2017 at 11:15 AM, Gilles <[hidden email]>
wrote:

> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>
>> On Sat, Jan 28, 2017 at 7:00 PM, Gilles <[hidden email]>
>> wrote:
>>
>> Hi.
>>>
>>> On Sat, 28 Jan 2017 14:38:21 -0500, Raymond DeCampo wrote:
>>>
>>> [...]
>>>>
>>>>>
>>>>> Now, for the contents of the "fraction" module.
>>>>>
>>>>> (1)
>>>>> My main current concern is the formatting-related classes; as for
>>>>> "complex", I think that
>>>>>  1. formatting (and I/O) is out of scope, and
>>>>>  2. the implementation were problematic in CM already.
>>>>> Hence, I'd prefer to drop support altogether.[1]
>>>>>
>>>>>
>>>>> I see your point of view, but allow me to play devil's advocate.  It
>>>>>
>>>> seems
>>>> natural to create the formatter for a new object, in particular a number
>>>> type, close to the type itself.  Making new objects and expecting
>>>> another
>>>> project to implement the formatting seems like what economists call an
>>>> externality.  I suppose it really depends how everyone maintaining text
>>>> would feel about it.  I am somewhat concerned about how the release
>>>> cycle
>>>> would work, in particular for the initial released, where text would
>>>> have
>>>> to wait for a release of numbers before including the formatting and
>>>> then
>>>> users would not have formatting until the next release of text.
>>>>
>>>> That said if the people maintaining text agree I have no objection.
>>>>
>>>>
>>> [Text] is also a new component. It is not unthinkable that its scope
>>> can encompass flexible formatting of such things as "fractions".
>>>
>>>
>> At the risk of raising a sore subject, wasn't the expectations of third
>> parties that someone else maintain code for them part of the impetus for
>> the current effort?
>>
>
> I'm not sure I understand what you wrote here.
>
> So shouldn't we get buy-in from the commons-text team
>> before we make a decision?
>>
>
> My proposal does not imply that someone else should implement
> the code.
>
> For example, if you feel confident that the input parsing and
> output formatting classes are useful and well implemented, you
> can start a discussion on this ML (with subject prefix [Text]),
> to inquire about objections to moving them to [Text].
> It seems that it was informally agreed that [Text] is a somewhat
> higher level component, i.e. that it can have runtime dependencies.
>
> As suggested, someone having a clear idea of what would be the use
>>> cases for formatting fraction, complex, and the likes, can create a
>>> new "commons-text-math-formatting" module (that would depend on the
>>> necessary modules from [Numbers]).
>>> From my experience with them, the formatting class from [Math] are
>>> not worth keeping.
>>> A lot of other codes should IMHO be given higher priority.
>>>
>>
>>
>> My point is that, generally, people using "fraction" can do with the
>>> constructors (to input data) and the accessors (to read result).
>>> Moreover, developers of "fraction" usually would not want to spend
>>> inordinate amounts of time to satisfy new formatting requests (that
>>> tend to translate into hundreds of lines of code, cf. CM).
>>>
>>>
>> The existence of some formats shouldn't result in an obligation to support
>> whatever formats are requested.
>>
>
> Certainly.
> But it is easier to justify as "out of scope", rather than "we don't
> care about format X".
> Then if someone comes up with a good library that can handle the
> "Commons Numbers" types, our incomplete code will become obsolete,
> and any work put in it will have been useless. The question is:
> Are there _currently_ any use-cases for it?
>
> If there aren't, please let's not rush to add it to the new component.
>
>
>>> The formatting code itself is not part of the concept, and so IMO
>>> effectively out of scope.
>>> There is no more sense to output "ugly" ASCII than there would be
>>> to generate any other output formats that would be more suited to
>>> represent mathematical concept (e.g. LaTeX).
>>>
>>> For logging and debugging purpose, "toString" should be quite fine.
>>>
>>>
>> I imagine that the greater value is in the parsing portion of the format
>> classes, not the output portion.
>>
>
> I do not have enough imagination. ;-)
>
>
Well the first use-case that comes to my mind is accepting user input from
some kind of GUI and turning it into a Fraction instance.  The second would
be extracting Fraction values from some kind of text representation, e.g.
CSV file, XML, etc.

But I think we are reaching the end of the useful phase of the discussion
so that said, I don't really have strong feelings on the matter.  I would
leave it in were it up to me but I wouldn't oppose you if you wanted to
take it out.
Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes

Gilles Sadowski
In reply to this post by Gilles Sadowski
On Sun, 29 Jan 2017 17:15:02 +0100, Gilles wrote:

> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>> On Sat, Jan 28, 2017 at 7:00 PM, Gilles
>> <[hidden email]>
>> wrote:
>>
>>> Hi.
>>>
>>> On Sat, 28 Jan 2017 14:38:21 -0500, Raymond DeCampo wrote:
>>>
>>>> [...]
>>>>>
>>>>> Now, for the contents of the "fraction" module.
>>>>>
>>>>> (1)
>>>>> My main current concern is the formatting-related classes; as for
>>>>> "complex", I think that
>>>>>  1. formatting (and I/O) is out of scope, and
>>>>>  2. the implementation were problematic in CM already.
>>>>> Hence, I'd prefer to drop support altogether.[1]
>>>>>
>>>>>
>>>>> I see your point of view, but allow me to play devil's advocate.  
>>>>> It
>>>> seems
>>>> natural to create the formatter for a new object, in particular a
>>>> number
>>>> type, close to the type itself.  Making new objects and expecting
>>>> another
>>>> project to implement the formatting seems like what economists
>>>> call an
>>>> externality.  I suppose it really depends how everyone maintaining
>>>> text
>>>> would feel about it.  I am somewhat concerned about how the
>>>> release cycle
>>>> would work, in particular for the initial released, where text
>>>> would have
>>>> to wait for a release of numbers before including the formatting
>>>> and then
>>>> users would not have formatting until the next release of text.
>>>>
>>>> That said if the people maintaining text agree I have no
>>>> objection.
>>>>
>>>
>>> [Text] is also a new component. It is not unthinkable that its
>>> scope
>>> can encompass flexible formatting of such things as "fractions".
>>>
>>
>> At the risk of raising a sore subject, wasn't the expectations of
>> third
>> parties that someone else maintain code for them part of the impetus
>> for
>> the current effort?
>
> I'm not sure I understand what you wrote here.
>
>> So shouldn't we get buy-in from the commons-text team
>> before we make a decision?
>
> My proposal does not imply that someone else should implement
> the code.
>
> For example, if you feel confident that the input parsing and
> output formatting classes are useful and well implemented, you
> can start a discussion on this ML (with subject prefix [Text]),
> to inquire about objections to moving them to [Text].
> It seems that it was informally agreed that [Text] is a somewhat
> higher level component, i.e. that it can have runtime dependencies.
>
>>> As suggested, someone having a clear idea of what would be the use
>>> cases for formatting fraction, complex, and the likes, can create a
>>> new "commons-text-math-formatting" module (that would depend on the
>>> necessary modules from [Numbers]).
>>> From my experience with them, the formatting class from [Math] are
>>> not worth keeping.
>>> A lot of other codes should IMHO be given higher priority.
>>
>>
>>> My point is that, generally, people using "fraction" can do with
>>> the
>>> constructors (to input data) and the accessors (to read result).
>>> Moreover, developers of "fraction" usually would not want to spend
>>> inordinate amounts of time to satisfy new formatting requests (that
>>> tend to translate into hundreds of lines of code, cf. CM).
>>>
>>
>> The existence of some formats shouldn't result in an obligation to
>> support
>> whatever formats are requested.
>
> Certainly.
> But it is easier to justify as "out of scope", rather than "we don't
> care about format X".
> Then if someone comes up with a good library that can handle the
> "Commons Numbers" types, our incomplete code will become obsolete,
> and any work put in it will have been useless. The question is:
> Are there _currently_ any use-cases for it?
>
> If there aren't, please let's not rush to add it to the new
> component.

Question about the parsing classes.

(1)
Why isn't there a
   public static Fraction parseFraction(String s)
method (similar to the JDK's subclasses of "java.lang.Number").

(2)
Why does method
   public Fraction parse(final String source)
in "FractionFormat" throw a subclass of "ArithmeticException" while
"parse" methods of the JDK's "Number" class throw
"NumberFormatException"
(a subclass of "IllegalArgumentException")?

(3)
Why does the parsing depend on "Locale"? ["Number" subclasses do not.]

(4)
Why use "StringBuffer"?

(5)
Why do several of the Javadoc comments in "FractionFormat" mention
"complex format"?


The more we look into these old classes ("@since 1.1"), the more we'll
find that they should have been deprecated, and that probably nobody
uses them (or we should have gotten some remarks about the above).


Regards,
Gilles

>>> The formatting code itself is not part of the concept, and so IMO
>>> effectively out of scope.
>>> There is no more sense to output "ugly" ASCII than there would be
>>> to generate any other output formats that would be more suited to
>>> represent mathematical concept (e.g. LaTeX).
>>>
>>> For logging and debugging purpose, "toString" should be quite fine.
>>>
>>
>> I imagine that the greater value is in the parsing portion of the
>> format
>> classes, not the output portion.
>
> I do not have enough imagination. ;-)
>
> Regards,
> Gilles
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes

Gilles Sadowski
In reply to this post by Raymond DeCampo
On Sun, 29 Jan 2017 17:02:05 -0500, Raymond DeCampo wrote:

> On Sun, Jan 29, 2017 at 11:15 AM, Gilles
> <[hidden email]>
> wrote:
>
>> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>>
>>> On Sat, Jan 28, 2017 at 7:00 PM, Gilles
>>> <[hidden email]>
>>> wrote:
>>>
>>> Hi.
>>>>
>>>> On Sat, 28 Jan 2017 14:38:21 -0500, Raymond DeCampo wrote:
>>>>
>>>> [...]
>>>>>
>>>>>>
>>>>>> Now, for the contents of the "fraction" module.
>>>>>>
>>>>>> (1)
>>>>>> My main current concern is the formatting-related classes; as
>>>>>> for
>>>>>> "complex", I think that
>>>>>>  1. formatting (and I/O) is out of scope, and
>>>>>>  2. the implementation were problematic in CM already.
>>>>>> Hence, I'd prefer to drop support altogether.[1]
>>>>>>
>>>>>>
>>>>>> I see your point of view, but allow me to play devil's advocate.
>>>>>> It
>>>>>>
>>>>> seems
>>>>> natural to create the formatter for a new object, in particular a
>>>>> number
>>>>> type, close to the type itself.  Making new objects and expecting
>>>>> another
>>>>> project to implement the formatting seems like what economists
>>>>> call an
>>>>> externality.  I suppose it really depends how everyone
>>>>> maintaining text
>>>>> would feel about it.  I am somewhat concerned about how the
>>>>> release
>>>>> cycle
>>>>> would work, in particular for the initial released, where text
>>>>> would
>>>>> have
>>>>> to wait for a release of numbers before including the formatting
>>>>> and
>>>>> then
>>>>> users would not have formatting until the next release of text.
>>>>>
>>>>> That said if the people maintaining text agree I have no
>>>>> objection.
>>>>>
>>>>>
>>>> [Text] is also a new component. It is not unthinkable that its
>>>> scope
>>>> can encompass flexible formatting of such things as "fractions".
>>>>
>>>>
>>> At the risk of raising a sore subject, wasn't the expectations of
>>> third
>>> parties that someone else maintain code for them part of the
>>> impetus for
>>> the current effort?
>>>
>>
>> I'm not sure I understand what you wrote here.
>>
>> So shouldn't we get buy-in from the commons-text team
>>> before we make a decision?
>>>
>>
>> My proposal does not imply that someone else should implement
>> the code.
>>
>> For example, if you feel confident that the input parsing and
>> output formatting classes are useful and well implemented, you
>> can start a discussion on this ML (with subject prefix [Text]),
>> to inquire about objections to moving them to [Text].
>> It seems that it was informally agreed that [Text] is a somewhat
>> higher level component, i.e. that it can have runtime dependencies.
>>
>> As suggested, someone having a clear idea of what would be the use
>>>> cases for formatting fraction, complex, and the likes, can create
>>>> a
>>>> new "commons-text-math-formatting" module (that would depend on
>>>> the
>>>> necessary modules from [Numbers]).
>>>> From my experience with them, the formatting class from [Math] are
>>>> not worth keeping.
>>>> A lot of other codes should IMHO be given higher priority.
>>>>
>>>
>>>
>>> My point is that, generally, people using "fraction" can do with
>>> the
>>>> constructors (to input data) and the accessors (to read result).
>>>> Moreover, developers of "fraction" usually would not want to spend
>>>> inordinate amounts of time to satisfy new formatting requests
>>>> (that
>>>> tend to translate into hundreds of lines of code, cf. CM).
>>>>
>>>>
>>> The existence of some formats shouldn't result in an obligation to
>>> support
>>> whatever formats are requested.
>>>
>>
>> Certainly.
>> But it is easier to justify as "out of scope", rather than "we don't
>> care about format X".
>> Then if someone comes up with a good library that can handle the
>> "Commons Numbers" types, our incomplete code will become obsolete,
>> and any work put in it will have been useless. The question is:
>> Are there _currently_ any use-cases for it?
>>
>> If there aren't, please let's not rush to add it to the new
>> component.
>>
>>
>>>> The formatting code itself is not part of the concept, and so IMO
>>>> effectively out of scope.
>>>> There is no more sense to output "ugly" ASCII than there would be
>>>> to generate any other output formats that would be more suited to
>>>> represent mathematical concept (e.g. LaTeX).
>>>>
>>>> For logging and debugging purpose, "toString" should be quite
>>>> fine.
>>>>
>>>>
>>> I imagine that the greater value is in the parsing portion of the
>>> format
>>> classes, not the output portion.
>>>
>>
>> I do not have enough imagination. ;-)
>>
>>
> Well the first use-case that comes to my mind is accepting user input
> from
> some kind of GUI and turning it into a Fraction instance.  The second
> would
> be extracting Fraction values from some kind of text representation,
> e.g.
> CSV file, XML, etc.

I'd agree about parsing the output of "toString()" (i.e. a
"Locale"-independent format, similar to what the JDK does for
subclasses of "Number").

But to be able to ensure valid input from CSV, XML, etc. would
require out-of-band information that will clutter the API to no
end.

> But I think we are reaching the end of the useful phase of the
> discussion
> so that said, I don't really have strong feelings on the matter.  I
> would
> leave it in were it up to me but I wouldn't oppose you if you wanted
> to
> take it out.

I want to take it out because the current code was unhelpful in the
one case where I needed it (to change the precision of the printed
value, which was about the simplest use-case). And I could not fix it
without a lot of work (to undo what the formatting instance was doing)
in order to get the same output as "toString()"!

You (and Rob) are most welcome to move the code to [Text] if you see
value in that implementation.


Regards,
Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes

Raymond DeCampo
On Tue, Jan 31, 2017 at 11:27 AM, Gilles <[hidden email]>
wrote:

> On Sun, 29 Jan 2017 17:02:05 -0500, Raymond DeCampo wrote:
>
>> On Sun, Jan 29, 2017 at 11:15 AM, Gilles <[hidden email]>
>> wrote:
>>
>> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>>>
>>>>
>>>> Well the first use-case that comes to my mind is accepting user input
>> from
>> some kind of GUI and turning it into a Fraction instance.  The second
>> would
>> be extracting Fraction values from some kind of text representation, e.g.
>> CSV file, XML, etc.
>>
>
> I'd agree about parsing the output of "toString()" (i.e. a
> "Locale"-independent format, similar to what the JDK does for
> subclasses of "Number").
>
> But to be able to ensure valid input from CSV, XML, etc. would
> require out-of-band information that will clutter the API to no
> end.
>

You've misunderstood.  You asked for use-cases.  Suppose you are consuming
an XML file and wish to end up with Fraction instances.  You would use your
friendly neighbor XML parser to extract the bits of text from the XML.
Then you would use FractionFormat to convert the text into Fraction
instances.  Just like you would use NumberFormat to convert bits of text
from the XML to integers.  This requires no additional code in the
FractionFormat class.



>
> But I think we are reaching the end of the useful phase of the discussion
>> so that said, I don't really have strong feelings on the matter.  I would
>> leave it in were it up to me but I wouldn't oppose you if you wanted to
>> take it out.
>>
>
> I want to take it out because the current code was unhelpful in the
> one case where I needed it (to change the precision of the printed
> value, which was about the simplest use-case). And I could not fix it
> without a lot of work (to undo what the formatting instance was doing)
> in order to get the same output as "toString()"!
>
> You (and Rob) are most welcome to move the code to [Text] if you see
> value in that implementation.
>
>
>
> Regards,
> Gilles
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes

Gilles Sadowski
On Tue, 31 Jan 2017 20:25:37 -0500, Raymond DeCampo wrote:

> On Tue, Jan 31, 2017 at 11:27 AM, Gilles
> <[hidden email]>
> wrote:
>
>> On Sun, 29 Jan 2017 17:02:05 -0500, Raymond DeCampo wrote:
>>
>>> On Sun, Jan 29, 2017 at 11:15 AM, Gilles
>>> <[hidden email]>
>>> wrote:
>>>
>>> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>>>>
>>>>>
>>>>> Well the first use-case that comes to my mind is accepting user
>>>>> input
>>> from
>>> some kind of GUI and turning it into a Fraction instance.  The
>>> second
>>> would
>>> be extracting Fraction values from some kind of text
>>> representation, e.g.
>>> CSV file, XML, etc.
>>>
>>
>> I'd agree about parsing the output of "toString()" (i.e. a
>> "Locale"-independent format, similar to what the JDK does for
>> subclasses of "Number").
>>
>> But to be able to ensure valid input from CSV, XML, etc. would
>> require out-of-band information that will clutter the API to no
>> end.
>>
>
> You've misunderstood.  You asked for use-cases.  Suppose you are
> consuming
> an XML file and wish to end up with Fraction instances.  You would
> use your
> friendly neighbor XML parser to extract the bits of text from the
> XML.
> Then you would use FractionFormat to convert the text into Fraction
> instances.  Just like you would use NumberFormat to convert bits of
> text
> from the XML to integers.  This requires no additional code in the
> FractionFormat class.

Misunderstood?  I'm not so sure.  What is the package of the
"NumberFormat" class?

"Double.valueOf", for example, does not parse localized representation
of numbers.  Providing the equivalent of "NumberFormat" instead of that
method is going to cause problems.[1]

So, to summarize, I think that
  1. "valueOf(String)" (and similarly "parseFraction(String)") are fine
     to implement in the [Numbers] component.[2]
  2. localized versions should be implemented in the [Text] component.

And similarly for "Complex" (although in that case, we may end up to
only accept the Cartesian representation).

Regards,
Gilles

[1] On systems where the default locale is not "US".
[2] Using private methods or package-scoped classes.

>>
>> But I think we are reaching the end of the useful phase of the
>> discussion
>>> so that said, I don't really have strong feelings on the matter.  I
>>> would
>>> leave it in were it up to me but I wouldn't oppose you if you
>>> wanted to
>>> take it out.
>>>
>>
>> I want to take it out because the current code was unhelpful in the
>> one case where I needed it (to change the precision of the printed
>> value, which was about the simplest use-case). And I could not fix
>> it
>> without a lot of work (to undo what the formatting instance was
>> doing)
>> in order to get the same output as "toString()"!
>>
>> You (and Rob) are most welcome to move the code to [Text] if you see
>> value in that implementation.
>>
>>
>>
>> Regards,
>> Gilles
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes

Raymond DeCampo
On Wed, Feb 1, 2017 at 4:43 AM, Gilles <[hidden email]> wrote:

> On Tue, 31 Jan 2017 20:25:37 -0500, Raymond DeCampo wrote:
>
>> On Tue, Jan 31, 2017 at 11:27 AM, Gilles <[hidden email]>
>> wrote:
>>
>> On Sun, 29 Jan 2017 17:02:05 -0500, Raymond DeCampo wrote:
>>>
>>> On Sun, Jan 29, 2017 at 11:15 AM, Gilles <[hidden email]>
>>>> wrote:
>>>>
>>>> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>>>>
>>>>>
>>>>>
>>>>>> Well the first use-case that comes to my mind is accepting user input
>>>>>>
>>>>> from
>>>> some kind of GUI and turning it into a Fraction instance.  The second
>>>> would
>>>> be extracting Fraction values from some kind of text representation,
>>>> e.g.
>>>> CSV file, XML, etc.
>>>>
>>>>
>>> I'd agree about parsing the output of "toString()" (i.e. a
>>> "Locale"-independent format, similar to what the JDK does for
>>> subclasses of "Number").
>>>
>>> But to be able to ensure valid input from CSV, XML, etc. would
>>> require out-of-band information that will clutter the API to no
>>> end.
>>>
>>>
>> You've misunderstood.  You asked for use-cases.  Suppose you are consuming
>> an XML file and wish to end up with Fraction instances.  You would use
>> your
>> friendly neighbor XML parser to extract the bits of text from the XML.
>> Then you would use FractionFormat to convert the text into Fraction
>> instances.  Just like you would use NumberFormat to convert bits of text
>> from the XML to integers.  This requires no additional code in the
>> FractionFormat class.
>>
>
> Misunderstood?  I'm not so sure.  What is the package of the
> "NumberFormat" class?
>
>
I was referring to your statement that "ensur[ing] valid input from CSV,
XML, etc. would require out-of-band information that will clutter the API
to no end."

There would be no need for the API (no matter which commons component it
lives in) to have any knowledge of the containing text format.




> "Double.valueOf", for example, does not parse localized representation
> of numbers.  Providing the equivalent of "NumberFormat" instead of that
> method is going to cause problems.[1]
>

There is no reason it could not be "in addition to", rather than "instead
of".



>
> So, to summarize, I think that
>  1. "valueOf(String)" (and similarly "parseFraction(String)") are fine
>     to implement in the [Numbers] component.[2]
>  2. localized versions should be implemented in the [Text] component.
>
> And similarly for "Complex" (although in that case, we may end up to
> only accept the Cartesian representation).
>
> Regards,
> Gilles
>
> [1] On systems where the default locale is not "US".
> [2] Using private methods or package-scoped classes.
>
>
>
>>> But I think we are reaching the end of the useful phase of the discussion
>>>
>>>> so that said, I don't really have strong feelings on the matter.  I
>>>> would
>>>> leave it in were it up to me but I wouldn't oppose you if you wanted to
>>>> take it out.
>>>>
>>>>
>>> I want to take it out because the current code was unhelpful in the
>>> one case where I needed it (to change the precision of the printed
>>> value, which was about the simplest use-case). And I could not fix it
>>> without a lot of work (to undo what the formatting instance was doing)
>>> in order to get the same output as "toString()"!
>>>
>>> You (and Rob) are most welcome to move the code to [Text] if you see
>>> value in that implementation.
>>>
>>>
>>>
>>> Regards,
>>> Gilles
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Numbers] Parsing and formatting classes

Gilles Sadowski
On Wed, 1 Feb 2017 07:36:32 -0500, Raymond DeCampo wrote:

> On Wed, Feb 1, 2017 at 4:43 AM, Gilles <[hidden email]>
> wrote:
>
>> On Tue, 31 Jan 2017 20:25:37 -0500, Raymond DeCampo wrote:
>>
>>> On Tue, Jan 31, 2017 at 11:27 AM, Gilles
>>> <[hidden email]>
>>> wrote:
>>>
>>> On Sun, 29 Jan 2017 17:02:05 -0500, Raymond DeCampo wrote:
>>>>
>>>> On Sun, Jan 29, 2017 at 11:15 AM, Gilles
>>>> <[hidden email]>
>>>>> wrote:
>>>>>
>>>>> On Sun, 29 Jan 2017 10:36:07 -0500, Raymond DeCampo wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>>> Well the first use-case that comes to my mind is accepting user
>>>>>>> input
>>>>>>>
>>>>>> from
>>>>> some kind of GUI and turning it into a Fraction instance.  The
>>>>> second
>>>>> would
>>>>> be extracting Fraction values from some kind of text
>>>>> representation,
>>>>> e.g.
>>>>> CSV file, XML, etc.
>>>>>
>>>>>
>>>> I'd agree about parsing the output of "toString()" (i.e. a
>>>> "Locale"-independent format, similar to what the JDK does for
>>>> subclasses of "Number").
>>>>
>>>> But to be able to ensure valid input from CSV, XML, etc. would
>>>> require out-of-band information that will clutter the API to no
>>>> end.
>>>>
>>>>
>>> You've misunderstood.  You asked for use-cases.  Suppose you are
>>> consuming
>>> an XML file and wish to end up with Fraction instances.  You would
>>> use
>>> your
>>> friendly neighbor XML parser to extract the bits of text from the
>>> XML.
>>> Then you would use FractionFormat to convert the text into Fraction
>>> instances.  Just like you would use NumberFormat to convert bits of
>>> text
>>> from the XML to integers.  This requires no additional code in the
>>> FractionFormat class.
>>>
>>
>> Misunderstood?  I'm not so sure.  What is the package of the
>> "NumberFormat" class?
>>
>>
> I was referring to your statement that "ensur[ing] valid input from
> CSV,
> XML, etc. would require out-of-band information that will clutter the
> API
> to no end."
>
> There would be no need for the API (no matter which commons component
> it
> lives in) to have any knowledge of the containing text format.

At the very least, the "Locale" of the input must be passed, or
problems
will ensue. "Locale" is "out-of-band" IMHO.


>> "Double.valueOf", for example, does not parse localized
>> representation
>> of numbers.  Providing the equivalent of "NumberFormat" instead of
>> that
>> method is going to cause problems.[1]
>>
>
> There is no reason it could not be "in addition to", rather than
> "instead
> of".

Agreed. That's what I wrote in the previous message (quoted below)...

And in this case, I'd rather stick to the layout of the JDK, which
emphasizes that the two functionalities are distinct.

You may not agree that [Text] is a better home, but then you have to
make the case why.

Please note that we should strive to make the "spin-offs" of Commons
Math as stable as possible.  I certainly would like to avoid any
potentiality of having to release Numbers 2.0 because we copied a 10
years old utility (that was probably never used outside of Commons
Math's error message formatting) without having looked at better
alternatives.

IMO, the game is currently about finding the truly low-level math
utilities, and make them really independent (that is bona-fide
components) so that their development become separate, guided
by internal consistency and not entangled with released scheduled
to fix unrelated stuff.

In the case of a "fraction", the accessors
  getNumerator()
  getDenominator()
are the only inputs required in order to create a string representation
of the instance.
These accessors are trivial (and thus unlikely to ever need an API
break) while the formatting part is far from trivial, and surely
would benefit from more elaborate functionality likely to also be
part of [Text].

I hope I made my point clear this time. :-}

Gilles

>>
>> So, to summarize, I think that
>>  1. "valueOf(String)" (and similarly "parseFraction(String)") are
>> fine
>>     to implement in the [Numbers] component.[2]
>>  2. localized versions should be implemented in the [Text]
>> component.
>>
>> And similarly for "Complex" (although in that case, we may end up to
>> only accept the Cartesian representation).
>>
>> Regards,
>> Gilles
>>
>> [1] On systems where the default locale is not "US".
>> [2] Using private methods or package-scoped classes.
>>
>>
>>
>>>> But I think we are reaching the end of the useful phase of the
>>>> discussion
>>>>
>>>>> so that said, I don't really have strong feelings on the matter.  
>>>>> I
>>>>> would
>>>>> leave it in were it up to me but I wouldn't oppose you if you
>>>>> wanted to
>>>>> take it out.
>>>>>
>>>>>
>>>> I want to take it out because the current code was unhelpful in
>>>> the
>>>> one case where I needed it (to change the precision of the printed
>>>> value, which was about the simplest use-case). And I could not fix
>>>> it
>>>> without a lot of work (to undo what the formatting instance was
>>>> doing)
>>>> in order to get the same output as "toString()"!
>>>>
>>>> You (and Rob) are most welcome to move the code to [Text] if you
>>>> see
>>>> value in that implementation.
>>>>
>>>>
>>>>
>>>> Regards,
>>>> Gilles
>>>>
>>>>
>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]