On Tue, Dec 21, 2010 at 8:36 AM, Richard Quadling <rquadl...@gmail.com>wrote:

> If I have an abstract class of Task and I want all subclasses of Task
> to have a private method _runTask, is there a way to enforce this?
>

I cannot think of a reason to force a class to have a specifically-named
*private* method. Since it's private, you cannot call it from outside the
class--not from its superclasses nor any subclasses. Since it cannot be
exposed in the class's API, there's no point in forcing a particular name.

If you are using the Template Method pattern [1], make the method protected.
This allows the superclass that declares the abstract method to call it and
forces its subclasses to implement it given the name you decide.

David

[1] http://c2.com/cgi/wiki?TemplateMethodPattern

Reply via email to