6.3. Delegation and Callback
Component-based design is “divide and conquer” with clear-cut compartmentalization: Sharing among bundles and services is strictly controlled. This poses a challenge to designing services that work together. For multiple callers to use a service, they must go through the same interface provided by the callee; at the same time, they may all want the callee in slightly different ways.
Suppose we are to design a news service, NewsService, whose HTML contents are needed by services for a pager, a touch panel, and a PC. The data are from the same source, but how they are displayed varies: text only on the pager, no dynamic contents on the touch panel, and full media on the PC.
The news service has a few options to deal ...
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