Summary
In this chapter, we familiarized ourselves with some concepts that help us to write better, more generic, and extendible software. We focused on abstract types, polymorphism, and self types in Scala.
We looked into the differences between generics and abstract type values in classes along with some examples and usage advice. Then we introduced the different types of polymorphism—subtype, parametric, and ad hoc. Finally, we went through self types in Scala and how to use them. We showed that self types provide a good way to encapsulate functionality and write modular code.
In the following chapter, we will look into the importance of separating the responsibilities of software components. We will also go through aspect-oriented programming. ...
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