Challenge: People's Heritage
Explore how to implement flexible polymorphism in Clojure using protocols and multimethods. Understand how to define multiple Person types with distinct behaviors for exercise, fun, and talk methods, and extend these with a Profession protocol to model occupations. This lesson helps you practice advanced protocol implementation to deepen your grasp of polymorphism in functional programming.
Motivation
You might have loved this chapter on polymorphism theory. This is a much more palpable concept for those who’ve learned other programming languages. And even though it isn’t very common in Clojure systems, it’s a great topic to learn about and understand how to use.
To solve the “people’s heritage” problem in this challenge, we recommend the use of the whole lesson on protocols. Even though you might be able to use multimethods, the concepts employed in protocols are more complex, so it would be very useful to exercise your skills in the implementation of protocols to improve your understanding.
Challenge
You receive a protocol ...