When you build a graphical user interface, you need a way to configure user interface objects, such as buttons, sliders, text fields, and menu items, and connect them to application-specific operations. For example, an application might provide a menu item to center selected text and another menu item to send a seating request to an airline reservation system. Finding a good way to connect user interface objects to application-specific operations is a common recurring problem.
One potential solution is to create application-specific subclasses of the user interface objects like menu items. For example, you could create a
CenterTextMenuItem class and a
SendSeatingRequestMenuItem class. However, there are a number ...