How evil would it be to enforce direct subclasses only?
Posted by timboudreau on May 1, 2009 at 2:43 PM EDT
Every now and then I get tempted to do this:
public abstract class AbstractType {
protected AbstractType() {
if (getClass().getSuperclass() != AbstractType.class) {
throw new AbuseOfInheritanceError();
}
}
}
I've seen so much code that was made less readable and more complicated by overuse of inheritance; there are cases where it would be doing the world a favor.
However, probably it would just make people want to shoot me. |
|
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- timboudreau's blog
- 622 reads






Comments
by i30817 - 2009-05-08 05:10
I sent a out of time Coin proposal to limit extension and implementation of interfaces outside a package. That's even more fascist.