December 2018
Beginner to intermediate
668 pages
15h 30m
English
With the inheritence approach, we can use the Template method pattern. Using the Template method pattern, we can create a default behavior in the root class and then create child classes to override the default behavior and implement new functionality.
For example, here is a Logger class that logs information into the file system:
public class Logger
{
public virtual void LogMessage(string message)
{
//This method logs information into file system
LogToFileSystem(message);
}
private void LogtoFileSystem(string message) {
//Log to file system
}
}
We have one LogMessage method that logs the message into the file system by calling the LogToFileSystem method. This method works fine until we wanted to extend the functionality. Suppose, ...
Read now
Unlock full access