Chapter 4

Case Study: Active–Passive Sets

To help cement the ideas explored in Chapters 1 to 3, this first case study develops several variants of a small program. The functionality to be implemented is a structure that keeps track of the states of a collection of objects. Each element from the collection can be in an active or passive state. States can be queried, and changed from passive to active, or from active to passive. The state of the entire collection can also be queried and modified by global operations that activate or deactivate all the elements. The service is implemented in a classic object-oriented style, a purely functional style, and a hybrid style that uses functional objects.

4.1 Object-Oriented Design

Consider first a standard, ...

Get Functional and Concurrent Programming: Core Concepts and Features 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.