Introducing the Master-Slave Pattern

All the subtasks in a Master-Slave pattern are identical, so this pattern helps you coordinate the work at runtime efficiently. This pattern differs from the Whole-Part pattern (see Chapter 17), which helps you create an efficient structure of the parts of your system during development. Figure 18-1 shows the structure of the Master-Slave pattern.

A good division between master and slaves is transparent to the clients that request the master to perform the task. The clients shouldn't be aware that a divide-and-conquer approach is being used.

images

The slaves that are doing the work shouldn't have any dependencies that affect that the way the work is divided. Dependencies make the solution inflexible and make it harder to achieve good separation between master and slaves.

images Taking the census

Every ten years, there's a census in the United States. The primary client that uses the data is Congress. They commission the Census Bureau to take the census. The Census Bureau hires many individuals to go out across the country to count the people. The census takers all do the same things — they're interchangeable, and if one finishes in his territory, he can be moved to help out in another territory.

The Census Bureau is the master of the Master-Slave architecture. ...

Get Pattern-Oriented Software Architecture For Dummies 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.