The Template-Method-Pattern (XDEV7111)

$1.99
0 ratings

Do you sometimes have a problem like this: I have 2 (or 20) Classes, they are similar in their basic algorithm (i.e., they have about the same sequence of doing things, but in detail, they are doing different things). You see that you have double code, but it's not so clear why. You'd like to get an abstraction to avoid the double code, but you are not sure about how to do so. If you derive from a Base-Class (Super-Class), doesn't that mean to carry the Algorithm to the derivatives? Or can we centralize the Algorithm in the base-class and keep the Variations for the Derivatives?

Yes, we can: with a design pattern called "Template-Method." It's helpful, if you have a fixed sequence of "something" but a lot of variations in that "something." Is it complicated to make or difficult to understand? Does it need sophisticated mechanics? No, it's just the good and straightforward use of the good old mechanism called inheritance.

I want this!
Size
99.3 KB
Copy product URL
$1.99

The Template-Method-Pattern (XDEV7111)

0 ratings
I want this!