Example class diagram

For the class diagram, let's imagine that we have an application that visualizes text from files. It might need to visualize the text, or might not depending on user actions. These files could be enormous or could be somewhere in a remote location. Here is how the proxy design pattern could help us achieve this:

According to the preceding diagram, we could use the FileReaderProxy objects and only when someone needs to access the file contents, we will delegate the functionality to the FileReaderReal. This design is nice and convenient because we can actually use the FileReader object; however, we can keep our application ...

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.