2.3.1 Dynamic and Flexible Programs

In a graphical user interface (GUI) you interact with the program using graphical controls such as buttons, lists, or check boxes. To make it possible for these controls to respond to your actions, an event-driven programming method is required. In this method every control can have its own response to an action, called an event. The event is a notification to the program that something has happened, for example that you have pressed a button, selected an item in a list, or ticked a check box.

Because every action of every control, in other words every event, can have its own logic, the program can respond separately to every single user action on every individual control. This makes it possible for event-driven programs to respond to actions dynamically.

Only the individual piece of logic associated with the event is performed when you trigger an event. This means the events can be executed in any order. This makes event-driven programs very flexible.

Many of the controls used in a GUI have powerful built-in functionality. They provide effective ways of interacting with the user and presenting and navigating data. As a result, you can create extremely compact applications with rich visual communication. Applications like this are easy to learn and to use.