Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#172 DesignForExtension task gives erroneous error.

release_3.2
closed
Lars Kühne
5
2012-10-10
2003-11-13
Rohan Lenard
No

Consider this class.

class X {
public boolean foo() {
return doFoo();
}

protected boolean doFoo() {
return true; // <--- have to return a value
}
};

Checkstyle gives a DesignForExtension error.
X.java:6:3: Method 'doFoo' is not designed for
extension - needs to be abstract, final or empty.

It can be "empty" because that can't compile.
It can't be abstract because the intention is to be able
to override it and a default "trivial implementation" is
provided.
If can't be final because that defeats the whole purpose.

Checkstyle should realise that there is a return type and
a "constant" value.

Discussion

  • Logged In: YES
    user_id=746148

    The first class I remember after reading this bug is
    java.awt.Component
    it's abtsract so the user have to subclass it.
    Also it provides a default implementation.
    So is this class designed for extention?
    The moral: when we should say that implementation is good
    enough for extention and when it's not.

    I don't want to say that we shoudn't fix this problem, but
    IMHO we should be very carefully with such changes.

     
  • Lars Kühne
    Lars Kühne
    2003-11-13

    Logged In: YES
    user_id=401384

    This is an RFE, not a bug - the software behaves exactly as
    the docs say. Closing this issue as a duplicate of RFE
    759147, see my comments there.