Logo-small

3.1.1 Listening without coupling

What is an Object Dependency Framework useful for?

Here is an interesting question that often comes up often when writing components. It is one that we faced when embedding our components. How do the components communicate with each other in a way that doesn't bind them together explicitly? That is, how does a child component send a message to its parent component without explicitly knowing who the parent is? Designing a component to refer to its parent is just a part of the solution since the interfaces of different parents may be different which would prevent the component from being reused in different contexts.

The main idea behind the framework is to set up announcers, define or reuse some announcements, let clients register interest in events and signal events. An event is an object representing an occurrence of a specific event. It is the place to define all the information related to the event occurrence. An announcer is responsible for registering interested clients and announcing events.

Announcements are not always the best way to establish communication between components. On one hand, announcements let you create loosely coupled components and thus maximize reusability. On the other hand, they introduce additional complexity when you may be able solve your communication problem with a simple message send.

Add a Note

Licensed under Creative Commons BY-NC-SA | Published using Pier |