Example class diagram

For the class diagram, let's imagine the following setting—we want our users to be able to download some data from a server and get it de-serialized in the form of objects. The server returns our data in encoded form, so we should decode it first, then parse it, and finally return the right objects. This involves many operations and makes things complicated. That's why we use a facade design pattern:

When clients use the preceding application, they will just have to interact with the DataReader. Internally, it will take care of downloading, decoding, and deserializing the data.

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.