• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Mutability and the Collections framework

 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Tony Morris's discussion of the apparent shortcomings of the PreparedStatement and CallableStatement interfaces, with respect to implementing redundant methods, got me thinking about the design of the Collections framework.

Can anyone explain the rationale behind the design of the List, Map and Set interfaces with respect to mutability. For example, I would expect to see the basic interfaces define the accessor methods and then have subinterfaces, e.g. MutableList, which define the mutator methods. With either implementation I would expect to see some way of determining whether the object in question is mutable, e.g. an isMutable() method or a Mutable marker interface.

Having to implement methods that explicitly throw an Exception to say they've not been implemented seems a little clumsy to me.

Is there a good reason for this design choice that I'm missing?

Further does anyone have any insight into the rationale behind the Statement interface and subinterface designs, which lead to the issues that Tony has highlighted?

I'm very keen to hear your opinions.

Jules
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that the Collections framework could have been better designed, as do a lot of others that I know. This is the reason behind http://jakarta.apache.org/commons/collections/ which aims to be better designed.

Still doesn't answer the question regarding java.sql.Statement - the only difference I can see is, one is documented to throw UnsupportedOperationException (Collections), and one is left up to the imagination (JDBC statements) to determine what the intention is.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic