On 4 May 2011 16:23, Gary Gregory <garydgreg...@gmail.com> wrote: > Ah, well, it would make it easier to port my current code: create subclasses > with the desired formatting and replace package names. Each subclass would > call toString(format) and that's it. The alternative is to either call > toString(format) from the call sites (sure, I could refactor that in a Utils > class) or have my factory classes create pair wrappers. But it seems easier > to keep reusing the current code than creating wrappers. If the class is > final, I have to go the Utils route, I do not have the choice. > > I just do not see the point of hand-cuffing users by making the class final. > I can always find new ways of shooting myself in the foot... ;)
Most of the time, open source should avoid final, because it places an unecessary burden on users. However, the phrase "immutable" has very specific meaning. BigDecimal and BigInteger are non-final "immutable" classes, and secure code must clone them to be absolutely safe. [lang] should follow best practice in Java, and "immutable" really does have a specific meaning. For your case, I would expect you to subclass Pair and create your own class with your own format. This is no different to what I will need to do here at OpenGamma to replace our pairs (now public and open source!) http://docs-static.opengamma.com/Latest%20Version/java/javadocs/com/opengamma/util/tuple/package-summary.html Stephen --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org