I was recently looking through some open source code PicketLink code. If you take a look at this class, you’ll see a number of concrete methods in an abstract class that do nothing. Is there any purpose whatsoever for this?
I thought about two things:
- If the method needs to be overriden by subclasses and not defined in the parent abstract class, why not simply make it abstract?
- If only some of the child classes actually need to implement the method, wouldn’t this indicate the need for a restructuring of the class hierarchy so that children are not forced to have methods that are not applicable?
While not the most common case, sometimes it is handy in the context of a template method. In this case there is a method that defines the flow, leaving the concrete implementation of some parts to its subclasses. In some cases a default concrete behavior is to do nothing, leaving the concrete method in the base class empty, but allowing customization in the subclass by overriding it.
HTH