Serving the curry
Duplicated code is a major code smell. We need to apply the extract method refactoring to remove this smell. For more information, refer to https://sourcemaking.com/refactoring/extract-method.
Instead of copying and pasting, we should reuse the code. One example of such code reuse is the template method design pattern. We have a common algorithm shell. This shell has blanks, that is, unspecified behavior. The blanks are filled with a specific behavior as needed. Too formal and pedantic? Let's come back to our real-world example and look at moms and their kids.
In our example, there are moms who have different professions. There are working moms, engineer moms, doctor moms, and teacher moms. All moms love their kids. This is the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access