@Marc-Andre @Marc-Andre and @janos @janos answers are very informative, consider mine to be an expansion to theirs... :)
@Marc-Andre and @janos answers are very informative, consider mine to be an expansion to theirs... :)
@Marc-Andre and @janos answers are very informative, consider mine to be an expansion to theirs... :)
You don't need a
new String()
below:String relativePath = new String(String.format("/api/%s/%s", apiKey, feature));
Inline more, inline often
I feel there are some places where you can neatly inline methods, reducing the number of variable assignments. For example, I may choose to write
createUrl()
in the following way:public URL createUrl(String feature) throws MalformedURLException { return new URL(PROTOCOL, WU_HOST, String.format("/api/%s/%s", apiKey, feature)); // or consider Java 8's String.join() method // return new URL(PROTOCOL, WU_HOST, String.join("/", "api", apiKey, feature)); }
You don't need a
new String()
below:String relativePath = new String(String.format("/api/%s/%s", apiKey, feature));
Inline more, inline often
I feel there are some places where you can neatly inline methods, reducing the number of variable assignments. For example, I may choose to write
createUrl()
in the following way:public URL createUrl(String feature) throws MalformedURLException { return new URL(PROTOCOL, WU_HOST, String.format("/api/%s/%s", apiKey, feature)); // or consider Java 8's String.join() method // return new URL(PROTOCOL, WU_HOST, String.join("/", "api", apiKey, feature)); }
You don't need a
new String()
below:String relativePath = new String(String.format("/api/%s/%s", apiKey, feature));
Inline more, inline often
I feel there are some places where you can neatly inline methods, reducing the number of variable assignments. For example, I may choose to write
createUrl()
in the following way:public URL createUrl(String feature) throws MalformedURLException { return new URL(PROTOCOL, WU_HOST, String.format("/api/%s/%s", apiKey, feature)); }