Topic on User talk:DKinzler (WMF)/Software Design Practices

DBarratt (WMF) (talkcontribs)

This part:

Interfaces make bad extension points, because they cannot be changed without breaking implementations; use abstract base classes instead.

Implies that the stability of an abstract class is greater than an interface. I would argue that an interface is more stable because it cannot be changed. Instead of changing it, a new interface must be created (or it is a breaking change, which is fine if the implementers have enough time to update).

In short, this statement is saying that the stability of the implementers is more important than the stability and consistency of the callers. I think the callers should be preferred over the implementers. Therefor, Interfaces should be preferred over (or used in addition to) abstract classes.

DKinzler (WMF) (talkcontribs)

This has all been discussed in length at phab:T193613. In short: introducing a new interface forces callers to do an instanceof check. Adding methods to an abstract base class don't force callers to do anything, and implementors are fine too, as long as the method has a default implementation. Interfaces cannot be changed in compliance with the deprecation policy. So abstract base classes are totally against what the textbook says, but our collective wisdom couldn't come up with anything better, even though nobody particularly likes the solution.

Reply to "Stability"