TAILIEUCHUNG - Lecture Programming languages (2/e): Chapter 16a - Tucker, Noonan

A conventional model of computation has the program prescribe the exact order of input. This model is supported by the four programming paradigms-imperative, objectoriented, functional, and logic. In this model, the program controls the sequence of steps that occur at run time, and the ordering of input plays a passive role in regulating how those steps are carried out. Moreover, this model supports algorithms that terminate once the input is exhausted. Chapter 16 provides knowledge of event-driven programming. | Programming Languages 2nd edition Tucker and Noonan Chapter 16 Event-Driven Programming Of all men’s miseries the bitterest is this, to know so much and to have control over nothing. Herodotus (484-432 BC) Contents Event-Driven Control Event Handling Three Examples Other Applications A conventional model of computation has the program prescribe the exact order of input. Programs terminate once the input is exhausted. Event-driven programs do not control the sequence in which input events occur. Examples GUI applications: Model-View-Controller design Embedded applications: cell phones car engines airplanes Event-Driven Control Computation as interaction [Stein] Computation is a community of persistent entities coupled together by their ongoing interactive behavior . Beginning and end, when present, are special cases that can often be ignored. Imperative and Event-Driven Paradigms Contrasted Figure Input to an event-driven program comes from autonomous event sources. Eg: human, robot sensors, engine sensors. Properties An event-driven program has no perceived stopping point. The traditional read-eval-print loop does not explicitly appear. An application processes an input and exits. Model-View-Controller (MVC) Model: the object being implemented. Ex: game, calculator. Controller: input mechanisms. Ex: buttons, menus, combo boxes. View: output. Ex: Tic-Tac-Toe Model Whose turn is it? State of the board. Has someone won? Are there no empty squares? Events in Java Subclasses of AWTEvent Event sources in Swing are subclasses of JComponent Program must listen for events Ex: for a JButton b (listener) Java Class AWTEvent and Its Subclasses* Figure Java EventListener Class Interface and Its Subclasses* Figure Widget Listener Interface JButton ActionListener actionPerformed JComboBox ActionListener actionPerformed JLabel JTextArea ActionListener actionPerformed JTextField ActionListener actionPerformed .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.