Re: BitSet vs BigInteger (false Android doc)
On 9/6/2011 1:41 PM, Jan Burse wrote:
Patricia Shanahan schrieb:
conversions. The combination of the comment in question and reading the
code shows that they did not take that path. Instead, they always
convert for bit manipulation and advise use of BitSet instead.
The Android comment can be corrected as follows:
"It is adviced to use BitSet if only positive bit patterns
come into play and if it is possible to use inline modifications."
But the comment should maybe also include a warning, that using
objects with inline modifications can lead to more programming
errors. Reasons are for example that the objects are now mutable
and thus various side effects can occur. Here is an example:
....
But I guess you all know about these dangers.
Maybe this is a matter of how programmers are expected to respond to
advice to use a class.
My first reaction, before committing to the change or writing a line of
code using the recommended class, would be to find and read its API
documentation. The only exception is if I'm already extremely familiar
with the class. Even if I have used some features, using it in a new
context may call for re-reading the documentation.
If the note came from a tutorial for novice programmers, I would agree
with you. If it comes from ordinary documentation, I think programmers
should be able to draw their own conclusions from the BitSet documentation.
Patricia