DEV Community

Discussion on: Design Patterns - Template Method

Collapse
 
samuraiseoul profile image
Sophie The Lionhart

When you show the code before pulling out the impact function perhaps it would be nice to point out the only difference between them is the operation done that Math.floor is applied to. Took me forever to realize they weren't the same as the rest of the code is identical. Other than that great easy to follow explanation!

Collapse
 
carlillo profile image
Carlos Caballero

Hi Scott!

Sorry for you time finding the difference in the codes. In fact, the template method is used only when there are small differences (or steps) in your algorithm. So, I though that a good example could be an algorithm of three steps in which two steps was common and one was difference.

Thanks for your comments ;-)