Changing the Delegate Class
It’s useful to specify in another
option what class to use in the place of the
BookSet. Imagine variations of
BookSet that fetch data from a relational database
and commit each record as it’s edited, or that perform some
degree of caching to answer certain queries quickly.
Changing the base class involves a lot of development and testing and is not easy to do on the fly. However, it’s possible to arrange things so that a user-written module is consulted to determine the delegate class at startup.
If you distribute your core application as source, the users can
always create a subclass to do what they want. However, subclassing
involves a lot of work; users must ensure that their new
BookSet
subclass still does
everything the COMBookSet
class expects. While possible, this pattern is not really
recommended for a complex class like BookSet.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access