|
Re: Changing an interface
On Tue, 22 Jul 2008 09:34:45 -0700, Pavel Minaev <int19h@gmail.com> wrote:
> The second approach is incorrect since the interface can be
> implemented as well as used; in fact, it is the whole point of having
> an interface! [...]
While I agree with pretty much everything else you wrote, I'll point out
that allowing the client to implement the interface is not "the WHOLE
point of having an interface".
There are examples of interfaces that are read-only as far as the client
is concerned. In those situations, it shouldn't be a breaking change to
add a member to the interface. For example, using an interface to control
accessibility (C# doesn't provide as fine-grained accessibility control as
some other languages, and so an interface might be used to keep an entire
class private except to some specific other class while allowing _some_ of
the members of the class to be public to the rest of the world).
Which is not the same as saying that doing so should be considered
lightly. Just that there are in fact scenarios in which changing the
interface after the fact wouldn't be disastrous.
Pete
|