the template pattern the template pattern is useful for removing duplicate codeit' an implementation to support the don' repeat yourself principle we discussed in when to use object-oriented programming it is designed for situations where we have several different tasks to accomplish that have somebut not allsteps in common the common steps are implemented in base classand the distinct steps are overridden in subclasses to provide custom behavior in some waysit' like generalized strategy patternexcept similar sections of the algorithms are shared using base class here it is in the uml formatbaseclass +do_process(+step (+step (+step (+step (task task +step (+step ( template example let' create car sales reporter as an example we can store records of sales in an sqlite database table sqlite is simple file-based database engine that allows us to store records using sql syntax python includes sqlite in its standard libraryso there are no extra modules required we have two common tasks we need to performselect all sales of new vehicles and output them to the screen in comma-delimited format output comma-delimited list of all salespeople with their gross sales and save it to file that can be imported to spreadsheet these seem like quite different tasksbut they have some common features in both caseswe need to perform the following steps connect to the database construct query for new vehicles or gross sales