June 2018
Intermediate to advanced
280 pages
7h 46m
English
The template method pattern is best implemented using an abstract class. The areas for which we know about the implementation will be provided; the default implementation and the areas that are to be kept open for implementation are marked abstract.
For example, think of a database fetch query at a very high level. We need to execute the following steps:
We can see that creating and closing the connection part will always remain the same. So, we can add this as part of the template implementation. The remaining methods can be implemented independently for different needs.
Read now
Unlock full access