unucirebon.prestasi.web.id Layanan Informasi 17 Jam
Telp/Fax : 021-8762002, 8762003, 8762004, 87912360
HP/SMS : 081 1110 4824 27, 0812 9526 2009, 08523 1234 000
WhatsApp : 0817 0816 486, 0812 9526 2009
email : _Hubungi Kami__ silahkan klik
Chatting dengan Staf :
ggkarir.com
ggiklan.com
Pilih Bahasa :   ID   EN   Permintaan Katalog / Brosur (GRATIS via POS)   Kelas Karyawan   Reguler
MangaOpen SourceKomunitas Ekonomi

   
Cari  
    Ilmu Informatika

    Sebelumnya  (Event (computing)) (Evergreen (software))  Berikutnya    

Event-driven programming

In computer programming, event-driven programming (EDP) or event-based programming is a programming paradigm in which the flow of the program is determined by events—e.g., sensor outputs or user actions (mouse clicks, key presses) or messages from other programs or threads.

Event-driven programming can also be defined as an application architecture technique in which the application has a main loop which is clearly divided down to two sections:

  • the first is event selection (or event detection)
  • the second is event handling.

In embedded systems the same may be achieved using interrupts instead of a constantly running main loop; in that case the former portion of the architecture resides completely in computer hardware.

Event-driven programs can be written in any language, although the task is easier in languages that provide high-level abstractions, such as closures. Some integrated development environments, such as Microsoft Visual Studio, provide code generation assistants that automate the most repetitive tasks required for event handling.

Contents

Event handlers

A trivial event handler

Because the code for checking for events and the main loop does not depend on the application, many programming frameworks take care of their implementation and expect the user to provide only the code for the event handlers. In this simple example there may be a call to an event handler called OnKeyEnter() that includes an argument with a string of characters, corresponding to what the user typed before hitting the ENTER key. To add two numbers, storage outside the event handler must be used. The implementation might look like below.

globally declare the counter K and the integer T.OnKeyEnter(character C){   convert C to a number N   if K is zero store N in T and increment K   otherwise add N to T, print the result and reset K to zero}

While keeping track of history is straightforward in a batch program, it requires special attention and planning in an event-driven program.

Exception handlers

In PL/1, even though a program itself may not be predominantly event driven, certain abnormal events such as a hardware error, overflow or "program checks" may occur that possibly prevents further processing. Exception handlers may be provided by "ON statements" in (unseen) callers to provide housekeeping routines to clean up afterwards before termination.

Creating event handlers

The first step in developing an event-driven program is to write a series of subroutines, or methods, called event-handler routines. These routines handle the events to which the main program will respond. For example, a single left-button mouse-click on a command button in a GUI program may trigger a routine that will open another window, save data to a database or exit the application. Many modern day programming environments provide the programmer with event templates so that the programmer only needs to supply the event code.

The second step is to bind event handlers to events so that the correct function is called when the event takes place. Graphical editors combine the first two steps: double-click on a button, and the editor creates an (empty) event handler associated with the user clicking the button and opens a text window so you can edit the event handler.

The third step in developing an event-driven program is to write the main loop. This is a function that checks for the occurrence of events, and then calls the matching event handler to process it. Most event-driven programming environments already provide this main loop, so it need not be specifically provided by the application programmer. RPG, an early programming language from IBM, whose 1960s design concept was similar to event driven programming discussed above, provided a built-in main I/O loop (known as the "program cycle") where the calculations responded in accordance to 'indicators' (flags) that were set earlier in the cycle.

Criticism and best practice

Event-driven programming is widely used in graphical user interfaces because it has been adopted by most commercial widget toolkits as the model for interaction. The design of those toolkits has been criticized, e.g., by Miro Samek, for promoting an over-simplified model of event-action, leading programmers to create error prone, difficult to extend and excessively complex application code. He writes,

Such an approach is fertile ground for bugs for at least three reasons:

  1. It always leads to convoluted conditional logic.
  2. Each branching point requires evaluation of a complex expression.
  3. Switching between different modes requires modifying many variables, which all can easily lead to inconsistencies.

Miro Samek, Who Moved My State?, C/C++ Users Journal, The Embedded Angle column (April 2003)

and advocates the use of state machines as a viable alternative.[1]

Stackless threading

An event driven approach is used in hardware description languages. A thread context only needs a cpu stack while actively processing an event, once done the cpu can move on to process other event-driven threads, that allows an extremely large number of threads to be handled. This is essentially a Finite-state machine approach.

See also

References

External links

    Sebelumnya  (Event (computing)) (Evergreen (software))  Berikutnya    





Tags: Event-driven programming, Ilmu Informatika, 2233, Event driven programming Programming paradigms Action Agent oriented Aspect oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing Relativistic programming Data driven Declarative (contrast: Imperative ) Constraint Dataflow Cell oriented ( spreadsheets ) Reactive Intensional Functional Logic Abductive logic Answer set Constraint logic Functional logic Indu, Event-driven programming, Bahasa Indonesia, Contoh Instruksi, Tutorial, Referensi, Buku, Petunjuk unucirebon, prestasi.web.id
 Kuliah Blended di 112 PTS Terbaik    Daftar Online    Cari Karir    Seluruh Perdebatan

 Permintaan Keringanan Uang Kuliah    Download Katalog    Perkuliahan Gratis    Program Kuliah Entrepreneur    Program Magister Ilmu Administrasi (MIA, MAdm)    Kuliah Reguler    Program Perkuliahan Paralel    Try Out Online Gratis    Waktu Shalat    Alqur'an Online    Buku Tutorial    Tips & Trik Tes Psikologi    Ensiklopedi Bebas    Berbagai Info
Manfaat Jeruk Lemon / Sitrun

Riboflavin (vitamin B2), Riboflavin (vitamin B2), Merawat tanaman Labu botol (Labu air), dsb.

Beritahu Rekan
Nama Saya

Email Saya

Email Rekan 1
⚽ harus diisi dengan benar

Rujukan Tambahan
silakan klik
Literatur Online

1. Universitas Yarsi Pratama - Universitas Yarsi Pratama - Kampus : Jl. Aria Jaya Santika No. 7, Pasir Nangka, Kec. Tigaraksa, Kab. Tangerang, Banten
2. STIE Widya Persada Jakarta - Sekolah Tinggi Ilmu Ekonomi Widya Persada Jakarta - Kampus :Jl. Hj. Tutty Alawiyah No.486, RW.5, Kalibata, Kec. Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12740
3. UWIKA Surabaya - Universitas Widya Kartika Surabaya - Kampus UWIKA : Jl. Sutorejo Prima Utara II No.1, Kalisari, Kec. Mulyorejo, Kota Surabaya, Jawa Timur 60112
4. Universitas Wijaya Kusuma Surabaya - Universitas Wijaya Kusuma Surabaya - Kampus : Jl. Dukuh Kupang XXV No.54, Dukuh Kupang, Kec. Dukuhpakis, Surabaya, Jawa Timur 60225
5. Universitas Teknologi Sulawesi Makassar - Universitas Teknologi Sulawesi Makassar - Kampus UTS Makassar : Jl. Talasalapang No.51A, Karunrung, Kec. Rappocini, Kota Makassar, Sulawesi Selatan 90222
6. Universitas Teknologi Nusantara - Universitas Teknologi Nusantara - Kampus UTN : Jl. Kedung Halang Pemda pangkalan II No.66, RT.01/RW.02, Kedunghalang, Kec. Bogor Utara, Kota Bogor, Jawa Barat 16158
kuliahkaryawan.sttsaptataruna.ac.id  |  s2-manajemen.co.id  |  stieppi.web.id  |  stti-stieni.ac.id  |  kelas-malam.co.id  |  kuliah-malam.co.id  |  kelas-sore.co.id  |  kuliah-sore-malam.co.id  |  kelas-pegawai.co.id  |  p2k.nusamandiri.ac.id  |  unnur.web.id