January 2020
Intermediate to advanced
532 pages
13h 31m
English
The delegation pattern is the idea of creating a new object by wrapping an existing one called the parent object. In order to reuse the object's features, the functions that have been defined for the new object can be delegated (also known as forwarded) to the parent.
Suppose that we have access to a banking library that provides some basic account management functionality. To understand how it works, let's take a look at the source code.
A bank account has been designed with the following mutable data structure:
mutable struct Account account_number::String balance::Float64 date_opened::Dateend
As part of the programming interface, the library also provides the field accessors (see ...
Read now
Unlock full access