Elliott C. Back: Internet & Technology

PANIC MODE JAVA

Posted in Code, Computers & Technology, Java, Law by Elliott Back on November 29th, 2005.

I’ve decided that Sun Micrososystems has screwed up with Java. See, they have a great API, but every now and then you find some kind of inconsistency that really makes you wonder “WHY.” For example, things in real life which can be compared to each other generally ought to implement the Comparable interface in Java so that you can compare them as objects. However, java . net . URL doesn’t implement Comparable, and therefore I am forced to conclude that a Uniform Resource Locator is fundamentally un-comparable. Except that it’s not. Every search engine has figured out how to handle URLs, but for some reason Java hasn’t.

Let me give you a hint–it’s not too hard. Just compare the protocol, the domain, and the paths. Then compare the query string. Of course there can be aliasing of all kinds on the server side, but couldn’t you lazy programmers at least have tried something?

This entry was posted on Tuesday, November 29th, 2005 at 11:00 pm and is tagged with uniform resource locator, lazy programmers, reason java, query string, panic mode, inconsistency, server side, api, hasn, protocol, interface, search engine, sun. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

3 Responses to “PANIC MODE JAVA”

  1. Charles E Coleman says:

    Another issue with URL, perhaps more serious, is cited by Bloch, Effective Java 2nd edition, p. 41:

    “…java.net.URL’s equals method relies on comparison of the IP addresses of the hosts associated with the URLs. Translating ahost name as an IP address can require network access, and it isn’t guaranteed to yield the same results over time”

    I have heard it said that it is best practice to always use URI over URL.

  2. Elliott Back says:

    Oh, it’s easy enough to work with. But a URI is not exactly a URL, so they should have built this funcationality in. And I’m allowed to ***** if I want to ;)

  3. inaequitas says:

    Well instead of bitching about it you’d find some elegant way of working besides it.

    So going further on into toURI and toString tells you that both URI and String are Comparable. Issue ends here.

    So maybe they weren’t so lazy after all. Given that, you know, they did Java.

Leave a Reply

Powered by WP Hashcash