Review/comment needed for the new public java.util.Base64 class (original) (raw)
Ulf Zibis Ulf.Zibis at CoSoCo.de
Tue Oct 30 18:44:23 UTC 2012
- Previous message: Review/comment needed for the new public java.util.Base64 class
- Next message: Review/comment needed for the new public java.util.Base64 class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Sherman,
thanks for your details. Has this discussion been on the list, and I have missed it?
I see a problem with hiding the "singleton" choice: Developers might tend to repetitively invoke public static Encoder getEncoder(int lineLength, byte[] lineSeparator) instead reusing the the same instance. (Note: It should not harm, to move the Objects.requireNonNull(lineSeparator); to the general private constructor.) In case of a public constant Encoder.RFC4648 ... developer would be aware about the re-usability of the encoder.
IMHO, the get...() methods are just waste of source lines and bytecode footprint.
But in contrast to the v4 I like the inner class approach: Base64.De/Encoder.
Little nit: In lines 89,100,127,128,138,149,159 the indentation is 5 instead 4.
-Ulf
Am 30.10.2012 02:51, schrieb Xueming Shen:
Ulf, my apology. Some how I missed your email.
We tried various prototypes for this simple utility class. See http://cr.openjdk.java.net/~sherman/base64/ The v4 might be close to the static constant approach you suggested. While It's hard to draw a clear line on which one is better, we concluded that the proposed approach provides the best balance among usability, readability and extensibility. For example, the "get" approach allows us to hide the "singleton" choice to the implementation. It provides a consistent interface "fixed" basic/url/mime type en/decoder and the configurable floating length/linefeed encoder. -Sherman On 10/29/12 11:15 AM, Ulf Zibis wrote: Hi Sherman,
can you give me a short answer please? -Ulf Am 23.10.2012 16:57, schrieb Ulf Zibis: Am 23.10.2012 15:04, schrieb Alan Bateman: I'm not sure that getUrlEncoder is the most suitable name to get a base64url encoder. The reason is that the method name makes it sound like it returns a URLEncoder or or at least an encoder for HTML forms. While more verbose, getBase64UrlEncoder is clear that it returns a base64url encoder.
I'm wondering, why there are those get... methods at all. Alternatively you could make the appropriate constructors and predifined static variants public. So one only should use: Base64.Encoder encoder = new Base64.Encoder(...); Base64.Encoder urlEncoder = Base64.Encoder.RFC4648URLSAFE; No need for those looong method names. -Ulf
- Previous message: Review/comment needed for the new public java.util.Base64 class
- Next message: Review/comment needed for the new public java.util.Base64 class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]