Ashok Felix wrote:You can use this sample to create your own class...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Actually, there's a major flaw in that class: It says it's "immutable", but neither the class itself, nor its methods are final.
Ulf Dittmer wrote:But the only variables -re and im- are final, so after they get something assigned to them in the constructor their values can't be changed any more. So any given object of the class is immutable.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
I therefore believe you may be breaching copyright by posting that class, and I am afraid I felt I have no option but to delete it. Sorry.Forbidden
You don't have permission to access /java/97data/Complex.java.html on this server.
Apache/2.2.15 (Red Hat) Server at introcs.cs.princeton.edu Port 80
Winston Gutkowski wrote:Read what Josh Bloch has to say about BigInteger and BigDecimal (which he wrote).
Winston Gutkowski wrote:
Ulf Dittmer wrote:But the only variables -re and im- are final, so after they get something assigned to them in the constructor their values can't be changed any more. So any given object of the class is immutable.
Right, but since nothing is final, I can create a subtype of Complex that completely rewrites the underlying logic, even making it mutable if I want.
Read what Josh Bloch has to say about BigInteger and BigDecimal (which he wrote).
Ulf Dittmer wrote:
The bigger question is: why would I use this class when what should be considered a standard library (Apache Commons Math) has one built in?
Campbell Ritchie wrote:I therefore believe you may be breaching copyright by posting that class, and I am afraid I felt I have no option but to delete it.
Henry Wong wrote:With this definition, it is talking more about the service provided. On the other end, it's is related to security, or at least, as some sort of protection against unintentional mistakes.
Considering that the Princeton class is provided for free as as source code, I think it is safe to assume that it is not targeting for the secure end of immutable ...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Ulf Dittmer wrote:But the only variables -re and im- are final, so after they get something assigned to them in the constructor their values can't be changed any more. So any given object of the class is immutable.
Right, but since nothing is final, I can create a subtype of Complex that completely rewrites the underlying logic, even making it mutable if I want.
Ulf Dittmer wrote:I think here we're getting into the territory Henry mentioned - differing interpretations of immutability. I think the most common one (which I was using) is object immutability - which this class has. Frankly, I have not come across a definition of immutability that concerns behavior (i.e., methods), just data, in the form of something like "if I have two objects that are equal, it is not possible to alter them so that they are no longer equal".
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
In which case it is all right, and I shall restore the discussion to this forum. Here it is (I hope). and I shall re‑post the actual code.Matthew Brown wrote: . . . they're released under GPLv3 (see Q + A section at the bottom of the page). . . .
Consider Paul's rocket mass heater. |