<< Customize Google | Home | How Many Milliseconds Ago Was That? >>

Immutability Of Interfaces

Erich Gamma: Since changing interfaces breaks clients you should consider them as immutable once you've published them. As a consequence when adding a new method to an interface you have to do so in a separate interface.

I hope the W3C people are listening. I have shouted about their adding methods to published interfaces 256 days ago, but you guys shouted me down.

Anybody want to argue the same point with Erich Gamma?



Re: Immutability Of Interfaces

On a related note, try to keep the public interface minimal. Fewer methods means there are fewer things you might have to change later. I also appreciate the article's discussion of Java "interface" versus "OO interface". Using something like Spring framework lets you focus on strictly the Java interface. If you construct objects directly, then the constructors also become part of the "interface" so to speak, meaning that they too cannot be changed without breaking clients.

Re: Immutability Of Interfaces

I didn't shout you down last time, and I agree this is a Bad Thing (tm). It is sometimes necessary, but most of the time when it is done, the people doing it delude themselves into thinking it is necessary when it isn't.

Add a comment Send a TrackBack