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 ...

Get Scala Functional Programming Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.