With the lens design pattern

In the previous subsection, we saw how complicated something such as changing one property of a nested class can be. We are going after nice, clean, and correct code, and we also don't want to go against the principles of Scala.

Luckily for us, cases such as the one we just mentioned previously are exactly the reason for the creation of the lens design pattern. In this chapter, we will see the Scalaz library for the first time in this book. It defines many functional programming abstractions for us, and we can easily use them straight away without worrying whether they follow some specific set of rules or not.

So, what are lenses anyway? We won't get too deep into the theoretical aspects here, as this is out of ...

Get Scala Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.