liveBook · Manning

Delegation principle

A design principle in which one class assigns work to another whose responsibilities make it more suitable for performing that work.

How 2 Manning books explain it

Software Design for Python Programmers

The Delegation Principle assigns work to another class whose responsibility and cohesion make it more suitable for performing that work.

How it is used
Uses delegation to assign work to the class whose responsibility and cohesion make it most suitable.
How deep it goes
Defines requester and delegate roles, demonstrates a Catalogue refactoring, and connects delegation to runtime-selectable strategies.
Examples
Uses Catalogue, Book, and Attributes for matching, then Sport with player and venue strategies for algorithm selection.
What you can do after
Apply it by extracting cohesive work into delegate objects and invoking them through stable requester methods.

Read how Software Design for Python Programmers explains delegation principle →

Object-Oriented Software Design in C++

A design principle in which one class assigns work to another class whose cohesive responsibilities make it more suitable to perform that work.

How it is used
Applies delegation while refactoring Catalogue to achieve cohesion and loose coupling.
How deep it goes
Defines requester–delegate roles and demonstrates one C++ search refactoring, stopping short of broader implementation guidance.
Examples
Uses a book Catalogue, Book objects, Attributes objects, and attribute-based searches as concrete delegation examples.
What you can do after
Apply it via cohesive classes that request specialized work without depending on the delegate's implementation.

Read how Object-Oriented Software Design in C++ explains delegation principle →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.