Event-driven programming known as a computer programming paradigm that used the occurrence of events to determine the control flow of the program. This type of application is designed to detect events as they occur, and use an appropriate event-handling procedure to deal with it, which normally use a callback function or method.
Theoretically, event-driven style of programming is supported in all programming languages, but they may different in the way of implement it, for example, it’s easier to implement in languages that provide high-level abstractions, such as closures. Besides, for other programming environments such as Adobe Flash, they are specifically tailored for triggering program code by events.
Generally, there is a main loop in an event-driven application that used to listen for events and triggers a callback function when there are events is detected.
Key features and characteristics of event-driven programming
Service oriented is a key features in event-driven programming that used to write programs that are made for services and it takes does not slow down the computer as service oriented only consume little of the computer processing power and usually services run in the background of OS.
In event driven programming, time driven is a paradigm, it’s a code that runs on a time trigger, time driven can be a specific code that runs on a specific time, which could be once an hour, once a week or once a month, this means it’s a pre-set to do task. For example, windows update is the example of time driven, which user can set when to update or when to check and download the update.
Event handlers is a type of function or method that run a specific action when a specific event is triggered. For example, it could be a button that when user click it, it will display a message, and it will close the message when user click the button again, this is an event handler.
Trigger functions in event-driven programming are a functions that decide what code to run when there are a specific event occurs, which are used to select which event handler to use for the event when there is specific event occurred.
Events include mouse, keyboard and user interface, which events need to be triggered in the program in order to happen, that mean user have to interacts with an object in the program, for example, click a button by a mouse, use keyboard to select a button and etc.
Simplicity of Programming and Ease of Development
Event-driven programming is simple and easier to program compared to other type of programming as it’s very visual, for example you can place a button by just select it and place it onto a form and write a code for it. Event-driven programming also easy for user to insert a pre-written code scripts into an existing application because it allows user to pause the code while it’s running. Which make developing using event-driven programming is easy.
Compare Event Driven Programming with Object-oriented Programming (OOP)
As mentioned above, event-driven programming known as a computer programming paradigm that used the occurrence of events to determine the control flow of the program, while objects-oriented programming (OOP) treats datafields as objects manipulated through pre-defined methods only and it constructed over four major principles, which are Encapsulation, Data Abstraction, Polymorphism and Inheritance.
In event-driven programming, a program is executed when they detected an event occur, for example, use mouse to click a button to show a message. Besides, in object-oriented programming, emphasis is given to data and classes are the main part of OOP, which mean classes are the blueprints of object and keep the data secure in the classes, only methods of particular classes are allowed to view the data.
The classes are also different between event-driven programming and object oriented programming. In OOP, classes can be created by own while in event-driven programming user must use the defined classes.
Object-oriented programming and event-driven programming may use together, which mentioned above that event-driven programming are support in all programming language, it’s just the way of implement it may different.
What is event-driven programming? (2017). Retrieved January 17, 2017, from http://www.computerhope.com/jargon/e/event-driven-prog.htm
1010, zakkcuthbert. (2014, November 7). Key features of event driven programs. Retrieved January 17, 2017, from https://zakkcuthbertunit14eventdrivenprogramming.wordpress.com/2014/11/07/key-features-of-event-driven-programs/
Event-driven programming (2017). . In Wikipedia. Retrieved from https://en.wikipedia.org/wiki/Event-driven_programming#Common_uses
Comparison of programming paradigms (2017). . In Wikipedia. Retrieved from https://en.wikipedia.org/wiki/Comparison_of_programming_paradigms
Studytonight. (2016). Object oriented programming concepts in C++. Retrieved January 17, 2017, from http://www.studytonight.com/cpp/cpp-and-oops-concepts.php