Re: Template method pattern in Java ???

From: Robert C. Martin (unclebob_at_objectmentor.com)
Date: 02/17/04


Date: Mon, 16 Feb 2004 22:30:16 -0600

On Mon, 16 Feb 2004 14:49:52 +0100, David Roden
<d.roden@cytainment.de> wrote:

>Robert C. Martin wrote:
>
>> [...] I like being able to declare a private pure
>> virtual function. What is says to me is that nobody but the base
>> should call it.
>
>Then why do you want to declare it in an interface?

Not an interface, an abstract class.

class Application {
  public:
    void Run() {
      Init();
      while (!done)
        Idle();
      Cleanup();
    }

  protected:
   bool done;

  private:
    virtual void Init() = 0;
    virtual void Idle() = 0;
    virtual void Cleanup() = 0;
};



Relevant Pages

  • Re: Template method pattern in Java ???
    ... What is says to me is that nobody but the base ... >Then why do you want to declare it in an interface? ... Not an interface, an abstract class. ...
    (comp.lang.java.help)
  • Re: Template method pattern in Java ???
    ... What is says to me is that nobody but the base ... >Then why do you want to declare it in an interface? ... Not an interface, an abstract class. ...
    (comp.object)
  • Re: Template method pattern in Java ???
    ... >>virtual function. ... What is says to me is that nobody but the base ... > Then why do you want to declare it in an interface? ... then he is practically confessing that it is not an interface! ...
    (comp.object)
  • Re: Template method pattern in Java ???
    ... >>virtual function. ... What is says to me is that nobody but the base ... > Then why do you want to declare it in an interface? ... then he is practically confessing that it is not an interface! ...
    (comp.lang.java.programmer)
  • Re: Template method pattern in Java ???
    ... >>virtual function. ... What is says to me is that nobody but the base ... > Then why do you want to declare it in an interface? ... then he is practically confessing that it is not an interface! ...
    (comp.lang.java.help)