A question about the Template Method design pattern

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Microsoft

    #1

    A question about the Template Method design pattern

    Is there a way of implementing something like the Template Method design
    pattern, but only dealing with static methods ?
    First, I realized that I can't have abstract static methods in the base
    class to be implemented in the derived classes.
    Second, I have tried to hide those methods of the base class, with the 'new'
    modifier, bub it doesn´t work.
    I would appreciate your help ver much.
    Thank you

    Juan M. Cervera


  • Juan M. Cervera

    #2
    Re: A question about the Template Method design pattern

    I´m sorry for the previous message where my name appears obviously wrong.
    Now it is corrected.

    "Microsoft" <jmcervera@gtfa drell.com> escribió en el mensaje
    news:uzu6lcaUDH A.652@tk2msftng p13.phx.gbl...[color=blue]
    > Is there a way of implementing something like the Template Method design
    > pattern, but only dealing with static methods ?
    > First, I realized that I can't have abstract static methods in the base
    > class to be implemented in the derived classes.
    > Second, I have tried to hide those methods of the base class, with the[/color]
    'new'[color=blue]
    > modifier, bub it doesn´t work.
    > I would appreciate your help ver much.
    > Thank you
    >
    > Juan M. Cervera
    >
    >[/color]


    Comment

    • Luca Minudel

      #3
      Re: A question about the Template Method design pattern

      while you can't use inheritance you can still use
      containment: use events and let container do the work in
      the event handling routine.

      hth (luKa)

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: A question about the Template Method design pattern

        Juan,
        In addition to the suggestion of using (static) Events.

        You might be able to use a static Delegate variable, which is set to the
        Template Method of the derived class.

        I would consider creating an implementation class that has the overridable
        template method in. Treat this implementation class as a singleton, where I
        have a single instance of the 'derived' class in the base classes static
        variable. Then my base's static method would call the method on this
        implementation class...

        I would consider making this implementation class nested with a visibility
        of protected to the base class. The 'derived' class would have their own
        derived implementation classes. The derived class would need to 'register'
        their implementation with the base class, I think I would use a custom
        setting in app.config to register this derived implementation class.

        Hope this helps
        Jay

        "Juan M. Cervera" <jmcervera@gtfa drell.com> wrote in message
        news:ukyGrjaUDH A.2200@TK2MSFTN GP11.phx.gbl...[color=blue]
        > I´m sorry for the previous message where my name appears obviously wrong.
        > Now it is corrected.
        >
        > "Microsoft" <jmcervera@gtfa drell.com> escribió en el mensaje
        > news:uzu6lcaUDH A.652@tk2msftng p13.phx.gbl...[color=green]
        > > Is there a way of implementing something like the Template Method design
        > > pattern, but only dealing with static methods ?
        > > First, I realized that I can't have abstract static methods in the base
        > > class to be implemented in the derived classes.
        > > Second, I have tried to hide those methods of the base class, with the[/color]
        > 'new'[color=green]
        > > modifier, bub it doesn´t work.
        > > I would appreciate your help ver much.
        > > Thank you
        > >
        > > Juan M. Cervera
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...