RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Use the Template Design Pattern to Customize a Base Class Service in a Derived Class

virtual member functions are widely used in object-oriented design but they don't always give you the flexibility you're after. For example, they don't let a derived class modify certain steps of a base class function while still retaining the original structure of the base class function. Learn how the Template design pattern solves this problem neatly.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

n classic object-oriented design, a base class defines an interface in the form of public virtual member functions. A derived class may either override these functions or use them as-is. Often, this "all or nothing" policy is too coarse. What you really need is a more flexible design that allows a subclass to customize the functionality of a base class's service without overriding it entirely. This article shows how to use the Template design pattern to achieve such flexibility.

How can a subclass redefine certain steps of an algorithm without changing the algorithm's structure?

Use the Template design pattern.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date