You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Christian Grobmeier <gr...@gmail.com> on 2009/03/17 08:48:12 UTC

[compress] Patch for SANDBOX-284

Hi all,

just made a quick fix for SANDBOX-284:
https://issues.apache.org/jira/browse/SANDBOX-284

I could not test it with a general working testcase, since this is a
platform problem and i have only OSX.
However, GUMP will not run on windows too, i guess. I think here is
some refactoring necessary to make
this code more testable.

Before I do this, this brings me to a question of codestyle. I prefer
to do quite less in the constructor. TarArchiveEntry does quite much,
and i think this is necessary in this case. The other option would be
to construct it empty and do all that stuff in a setter, which would
bring no benefit. To make it testable, I would have to extract some
methods from the constructor. Normally I would mark them private, but
private methods cannot be tested, except with reflection.

My question is, is it common use at commons to test with reflection in
that special and rare cases? Or should I mark the package scoped, just
for the sake of testability?

I think I would prefer option one, even when it reminds me on the
story with cannonballs and that birds.

Cheers,
Christian

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


Re: [math] suggesting rational function and trigonometric functions classes

Posted by Bernhard Grünewaldt <be...@gruenewaldt.net>.
Hi Ted,

As you suggested I opened a ticket for this issue:

https://issues.apache.org/jira/browse/MATH-250

:)

- Bernhard

Ted Dunning schrieb:
> Reasoning purely by symmetry, doesn't it seem that where you are headed here
> is toward an extended rational polynomial class that handles rational
> polynomials of a base variable and simple functions of a base variable (such
> as trig functions, log and exp)?
> 
> If so, then having some kind of unified class would probably be a good
> thing.  You could pretty easily support the same functions as the current
> Polynomial class (derivative, multiply, add, negate and so on).  The
> question of log(-1) and sqrt(-1) is likely to come up, but if you add a
> convention for complaining about these, then you should be good to go.
> 
> The next step is to file a JIRA where discussions like this can have a home.
> 
> On Tue, Mar 17, 2009 at 9:01 AM, Bernhard Grünewaldt <
> bernhard@gruenewaldt.net> wrote:
> 
>> Hi,
>>
>> I used already the classes of the analysis package:
>> http://commons.apache.org/math/userguide/analysis.html
>>
>> There is already a fine class for Polynomial Functions which can calculate
>> the derivation:
>>
>> PolynomialFunction.derivative()
>>
>>
>> I would like to suggest a class called "RationalFunction" which can do
>> almost the same but for (you guessed it) Rational Functions.
>>
>> Suggested methods are: derivative() , add(RationalFunction r), a.s.o.
>>
>> http://en.wikipedia.org/wiki/Rational_function
>>
>> If this is something which you would like to have I will start coding it
>> to provide a patch.
>>
>> The next thing is "Trigonometric Functions" and their derivatives:
>>
>>
>> http://en.wikipedia.org/wiki/Trigonometric_function_derivations#Derivatives_of_trigonometric_functions
>>
>> It would also be nice to have classes for that type of function.
>>
>>
>> - Bernhard
>>
>>
>> ---------------------------------------------------------------------
>> 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: [math] suggesting rational function and trigonometric functions classes

Posted by Ted Dunning <te...@gmail.com>.
Reasoning purely by symmetry, doesn't it seem that where you are headed here
is toward an extended rational polynomial class that handles rational
polynomials of a base variable and simple functions of a base variable (such
as trig functions, log and exp)?

If so, then having some kind of unified class would probably be a good
thing.  You could pretty easily support the same functions as the current
Polynomial class (derivative, multiply, add, negate and so on).  The
question of log(-1) and sqrt(-1) is likely to come up, but if you add a
convention for complaining about these, then you should be good to go.

The next step is to file a JIRA where discussions like this can have a home.

On Tue, Mar 17, 2009 at 9:01 AM, Bernhard Grünewaldt <
bernhard@gruenewaldt.net> wrote:

> Hi,
>
> I used already the classes of the analysis package:
> http://commons.apache.org/math/userguide/analysis.html
>
> There is already a fine class for Polynomial Functions which can calculate
> the derivation:
>
> PolynomialFunction.derivative()
>
>
> I would like to suggest a class called "RationalFunction" which can do
> almost the same but for (you guessed it) Rational Functions.
>
> Suggested methods are: derivative() , add(RationalFunction r), a.s.o.
>
> http://en.wikipedia.org/wiki/Rational_function
>
> If this is something which you would like to have I will start coding it
> to provide a patch.
>
> The next thing is "Trigonometric Functions" and their derivatives:
>
>
> http://en.wikipedia.org/wiki/Trigonometric_function_derivations#Derivatives_of_trigonometric_functions
>
> It would also be nice to have classes for that type of function.
>
>
> - Bernhard
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
Ted Dunning, CTO
DeepDyve

[math] suggesting rational function and trigonometric functions classes

Posted by Bernhard Grünewaldt <be...@gruenewaldt.net>.
Hi,

I used already the classes of the analysis package:
http://commons.apache.org/math/userguide/analysis.html

There is already a fine class for Polynomial Functions which can calculate
the derivation:

PolynomialFunction.derivative()


I would like to suggest a class called "RationalFunction" which can do
almost the same but for (you guessed it) Rational Functions.

Suggested methods are: derivative() , add(RationalFunction r), a.s.o.

http://en.wikipedia.org/wiki/Rational_function

If this is something which you would like to have I will start coding it
to provide a patch.

The next thing is "Trigonometric Functions" and their derivatives:

http://en.wikipedia.org/wiki/Trigonometric_function_derivations#Derivatives_of_trigonometric_functions

It would also be nice to have classes for that type of function.


- Bernhard


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


Re: [compress] Patch for SANDBOX-284

Posted by Christian Grobmeier <gr...@gmail.com>.
> Yes, understood now, thanks.
>
> In which case maybe it is worth refactoring into two package-protected
> methods so Unit tests can exercise them easily. It would be useful for
> a Windows developer to be able to test the Unix code too.
>
> Also consider doing this for any other bits of code that depend on the
> run-time environment.

OK I will keep that in mind and try to do so.
Cheers
Christian

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


Re: [compress] Patch for SANDBOX-284

Posted by sebb <se...@gmail.com>.
On 18/03/2009, Christian Grobmeier <gr...@gmail.com> wrote:
> > Sorry, I still don't understand why refactoring would be needed in
>  > order for the code to be tested using CI?
>  >
>  > I must be missing something - can you explain?
>  > I'm curious to know what the problem is that requires refactoring for CI.
>
>
> Sorry for beeing unclear. Refactoring is big term for "extracting a method".
>  Currently code is:
>
>  if( System.Property.OS == Windows)
>    // do windows related path stuff
>  else
>   // do *nix related path stuff
>  end if
>
>  The windows related stuff has roundabout 10 lines of code and can
>  never be reached in CI, since those are  running on unix. Means, that
>  aprt is never beeing tested.
>
>  If we would extract a method with the windows stuff, the method could
>  be tested (by reflection, cause it is private).
>
>  Hope this makes it more clear now :-)

Yes, understood now, thanks.

In which case maybe it is worth refactoring into two package-protected
methods so Unit tests can exercise them easily. It would be useful for
a Windows developer to be able to test the Unix code too.

Also consider doing this for any other bits of code that depend on the
run-time environment.

> Cheers
>
>  ---------------------------------------------------------------------
>  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: [compress] Patch for SANDBOX-284

Posted by Christian Grobmeier <gr...@gmail.com>.
> Sorry, I still don't understand why refactoring would be needed in
> order for the code to be tested using CI?
>
> I must be missing something - can you explain?
> I'm curious to know what the problem is that requires refactoring for CI.

Sorry for beeing unclear. Refactoring is big term for "extracting a method".
Currently code is:

if( System.Property.OS == Windows)
   // do windows related path stuff
else
  // do *nix related path stuff
end if

The windows related stuff has roundabout 10 lines of code and can
never be reached in CI, since those are  running on unix. Means, that
aprt is never beeing tested.

If we would extract a method with the windows stuff, the method could
be tested (by reflection, cause it is private).

Hope this makes it more clear now :-)
Cheers

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


Re: [compress] Patch for SANDBOX-284

Posted by sebb <se...@gmail.com>.
On 18/03/2009, Christian Grobmeier <gr...@gmail.com> wrote:
> Hi,
>
> >>  So we don't have a continues
>  >>  integration test for exactly that problem.
>  >
>  > IMO it does not matter not having a continuous integration test so
>  > long as the OS-specific stuff is tested from time to time by someone,
>  > and particularly before release.
>  >
>  > Might be a good idea to make a note in the documentation to warn
>  > future maintainers/release managers of the need to test on multiple
>  > OSes.
>  >
>
>
> OK - then no problem.
>
>
>  >>  Question is, if we should refactor more to test this special scenario or not.
>  >
>  > What do you mean by refactor?
>
>
> I meant, if we want to check this by CI we have to refactor some more
>  code in this class. But I agree to your statement above and would like
>  to let the code as it is now atm

Sorry, I still don't understand why refactoring would be needed in
order for the code to be tested using CI?

I must be missing something - can you explain?
I'm curious to know what the problem is that requires refactoring for CI.

>  Cheers
>
>
>  ---------------------------------------------------------------------
>  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: [compress] Patch for SANDBOX-284

Posted by Christian Grobmeier <gr...@gmail.com>.
Hi,
>>  So we don't have a continues
>>  integration test for exactly that problem.
>
> IMO it does not matter not having a continuous integration test so
> long as the OS-specific stuff is tested from time to time by someone,
> and particularly before release.
>
> Might be a good idea to make a note in the documentation to warn
> future maintainers/release managers of the need to test on multiple
> OSes.
>

OK - then no problem.

>>  Question is, if we should refactor more to test this special scenario or not.
>
> What do you mean by refactor?

I meant, if we want to check this by CI we have to refactor some more
code in this class. But I agree to your statement above and would like
to let the code as it is now atm

Cheers

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


Re: [compress] Patch for SANDBOX-284

Posted by sebb <se...@gmail.com>.
On 18/03/2009, Christian Grobmeier <gr...@gmail.com> wrote:
> Hi,
>
>  test works on OSX - but we cannot really test on *nix boxes if the
>  name-normalizing works on windows too. "if system == windows" wouldn't
>  give back "windows" at the gump servers. So we don't have a continues
>  integration test for exactly that problem.

IMO it does not matter not having a continuous integration test so
long as the OS-specific stuff is tested from time to time by someone,
and particularly before release.

Might be a good idea to make a note in the documentation to warn
future maintainers/release managers of the need to test on multiple
OSes.

>  Question is, if we should refactor more to test this special scenario or not.

What do you mean by refactor?

>  Cheers
>
> Christian
>
>
>
>
>  On Tue, Mar 17, 2009 at 4:14 PM, Stefan Bodewig <bo...@apache.org> wrote:
>  > On 2009-03-17, Christian Grobmeier <gr...@gmail.com> wrote:
>  >
>  >> Hi
>  >
>  >>>>>  I could not test it with a general working testcase, since this is a
>  >>>>>  platform problem and i have only OSX.
>  >
>  >>> I have written some rudimentary tests that pass on Windows.
>  >
>  >> can those test run successfully on *NIX too? (Gump is running those on
>  >> a unix platform too).
>  >
>  > I think so (will check tonight when I'm back home - lunch break
>  > hacking involves Windows, night time it is Linux 8-)
>  >
>  > Stefan
>  >
>  > ---------------------------------------------------------------------
>  > 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: [compress] Patch for SANDBOX-284

Posted by Christian Grobmeier <gr...@gmail.com>.
Hi,

test works on OSX - but we cannot really test on *nix boxes if the
name-normalizing works on windows too. "if system == windows" wouldn't
give back "windows" at the gump servers. So we don't have a continues
integration test for exactly that problem.
Question is, if we should refactor more to test this special scenario or not.

Cheers
Christian



On Tue, Mar 17, 2009 at 4:14 PM, Stefan Bodewig <bo...@apache.org> wrote:
> On 2009-03-17, Christian Grobmeier <gr...@gmail.com> wrote:
>
>> Hi
>
>>>>>  I could not test it with a general working testcase, since this is a
>>>>>  platform problem and i have only OSX.
>
>>> I have written some rudimentary tests that pass on Windows.
>
>> can those test run successfully on *NIX too? (Gump is running those on
>> a unix platform too).
>
> I think so (will check tonight when I'm back home - lunch break
> hacking involves Windows, night time it is Linux 8-)
>
> Stefan
>
> ---------------------------------------------------------------------
> 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: [compress] Patch for SANDBOX-284

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-03-17, Christian Grobmeier <gr...@gmail.com> wrote:

> Hi

>>>>  I could not test it with a general working testcase, since this is a
>>>>  platform problem and i have only OSX.

>> I have written some rudimentary tests that pass on Windows.

> can those test run successfully on *NIX too? (Gump is running those on
> a unix platform too).

I think so (will check tonight when I'm back home - lunch break
hacking involves Windows, night time it is Linux 8-)

Stefan

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


Re: [compress] Patch for SANDBOX-284

Posted by Christian Grobmeier <gr...@gmail.com>.
Hi

>>>  I could not test it with a general working testcase, since this is a
>>>  platform problem and i have only OSX.
>
> I have written some rudimentary tests that pass on Windows.

can those test run successfully on *NIX too? (Gump is running those on
a unix platform too). I can test the test on OSX tomorrow if needed

And thanks for the rest of comments

Christian

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


Re: [compress] Patch for SANDBOX-284

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-03-17, sebb <se...@gmail.com> wrote:

> On 17/03/2009, Christian Grobmeier <gr...@gmail.com> wrote:
>> Hi all,

>>  just made a quick fix for SANDBOX-284:
>>  https://issues.apache.org/jira/browse/SANDBOX-284

>>  I could not test it with a general working testcase, since this is a
>>  platform problem and i have only OSX.

I have written some rudimentary tests that pass on Windows.

>>  Before I do this, this brings me to a question of codestyle. I prefer
>>  to do quite less in the constructor. TarArchiveEntry does quite much,
>>  and i think this is necessary in this case.

I agree that it seems to be necessary.  Note that the different
constructors behaved differently when it came to modifiying the name -
the reported bug only applied to the File-arg constructor which meant

new TarArchiveEntry("C:\\")

worked and 

new TarArchiveEntry(new File("C:\\"))

did not - and using absolute path names in either constructor lead to
different results.  I've fixed this at the same time (as well as the
setName method).

> Also, any instance fields that are mutable mean that synch. is likely
> to be needed to ensure that the class is thread-safe. Immutable
> classes are always thread-safe, and easier to test because they only
> have one state.

Many or TarArchiveEntry's fields are mutable and need to be for the
different use-cases.  They could be final for entries just read from
an archive but likely need to be mutable when you construct a entry to
be written (or it needs a big constructor with many many arguments).

Still the class is a bit strange in that it uses StringBuffers to
store names that are either completely overwritten or kept immutable
(i.e. the name is never modified internally - it can be set to a
completely different name, though).

> However, if the class is not intended to be thread-safe, then of
> course the mutable fields are not a problem.

It doesn't look as if it ever was intended to be thread safe.

Stefan

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


Re: [compress] Patch for SANDBOX-284

Posted by sebb <se...@gmail.com>.
On 17/03/2009, Christian Grobmeier <gr...@gmail.com> wrote:
> Hi all,
>
>  just made a quick fix for SANDBOX-284:
>  https://issues.apache.org/jira/browse/SANDBOX-284
>
>  I could not test it with a general working testcase, since this is a
>  platform problem and i have only OSX.
>  However, GUMP will not run on windows too, i guess. I think here is
>  some refactoring necessary to make
>  this code more testable.

Not sure what Gump has to do with this.

>  Before I do this, this brings me to a question of codestyle. I prefer
>  to do quite less in the constructor. TarArchiveEntry does quite much,
>  and i think this is necessary in this case. The other option would be
>  to construct it empty and do all that stuff in a setter, which would
>  bring no benefit. To make it testable, I would have to extract some
>  methods from the constructor. Normally I would mark them private, but
>  private methods cannot be tested, except with reflection.
>
>  My question is, is it common use at commons to test with reflection in
>  that special and rare cases? Or should I mark the package scoped, just
>  for the sake of testability?

Constructors should not generally call overridable methods, as these
can cause problems if the class is ever extended. So make any such
methods final.

Also, any instance fields that are mutable mean that synch. is likely
to be needed to ensure that the class is thread-safe. Immutable
classes are always thread-safe, and easier to test because they only
have one state.

However, if the class is not intended to be thread-safe, then of
course the mutable fields are not a problem.

>  I think I would prefer option one, even when it reminds me on the
>  story with cannonballs and that birds.
>
>  Cheers,
>  Christian
>
>  ---------------------------------------------------------------------
>  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