Wednesday, May 30, 2018

Template Method Design Pattern by Example

This pattern falls under behavioral design patterns, and, as the name suggests, it defines the template which can be used further to create something by using it. You can think of it like stencils, you can create designs on a wall or other surface without much effort; you just need to choose the color and apply the paint.

Let’s understand this with an example. We will be implementing a Logger which is capable of logging in multiple places like a database, a file or sending logs in an email. We will start with one simple solution and will refactor it gradually to see how the template method pattern can be useful for us.



from DZone.com Feed https://ift.tt/2IZJ5Jl

No comments:

Post a Comment