+91 9945200008     support@uttaracomputers.com
LOGIN     REGISTER    

[Design Patterns]:[Audio#2 : Template method]

0
0

Concept of Base class ==> Having private virtual Functions ==> Unable to understand;

Should it always be private can’t it be protected in Template Design Pattern?

 

  • You must to post comments
0
0

Can you please elaborate the question? Add more details so that I can get the context of the question.

  • You must to post comments
0
0

Hello Mr Shastry,

As per the Template Design, expained in the session (Audio#2),

Base Class Can provide the private virtaul function, if it requres to let the dervied class tweek the algorithms;

i would like to understand the difference between private virtual and protected virtual fucntion; What capability does it add to the class/does it enforces anything ?;

All the exampled (Online) have protected virtual;

 

[suggestion] Also it would good to add little details about Hooks to make the discussion complete on Template Pattern;

 

Thanks & have a nice day

zafar

 

  • You must to post comments
0
0

Virtual private is required here so that derived class cannot modify the template or the order in which functions are called.

If any website mentions protected virtual for the same purpose may be you can try a sample code and check if derived class is able to modify the order in which the virtual functions are called ? That would help clarify.

Regarding hooks, do you mean c++ template hooks ? We are more focused in the template session on the pattern description in general and not the specific language construct.

  • You must to post comments
0
0

Hello Mr Shastry,

Order in which the function is called cannot be changed (irrespective if the fucntion is defined as private virtual or protected virtual), as it is non-virtual function at base class;

i wnated to understand why there was a stress on only private virtual function;

>> Hooks are part of the Template method and not specific to C++,  it just lets the derived class know that before and after the function.

>> Ex ASP.net Page life cycle>> PreLoad, Load, LoadComplete (here PreLoad and LoadComplete are Hooks functions (virtual functions))

Thanks

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.