What is Event Oriented Programming?

  • What is event-oriented programming?
  • What Differs Between Event-Oriented Programming and Object-Oriented Programming?
  • What languages can we cite that are event-oriented?
asked by anonymous 13.08.2015 / 17:37

2 answers


What is event-oriented programming?

That's when you write code to respond to events.

In event-oriented programming, a routine that is specialized in monitoring events warns the code specific to responding to a particular event that the event that it expected occurred; and then the newly prompted code responds to the event.

What differs Event-oriented programming and Object-oriented programming?

These are not paradigms that can be compared with each other. It would be like describing the differences between a raven and a desk: D

The answers to this question are very assertive about describing object orientation: What are the practical advantages of using object orientation in day to day development team? .

Now notice that you can define objects, their relationships, and their responsibilities, and then make these objects respond to events by scheduling event-oriented code.

What languages can we name that are event-oriented?

I do not know "event-oriented" languages. Strictly speaking you can program event-oriented in any language. Just write an event monitor that warns you of the code that is interested in the events it is monitoring.

There are some languages that greatly facilitate event-oriented programming: C #, Visual Basic, Delphi.

There are others that have no special facilitator, but where you can use design patterns like observable to respond to events - for example Java.

Example of event orientation

A common use of event orientation is in programming graphical user interfaces.

See C # WinForms, for example.

In it you write code that will respond for example to a user click on a particular button, and you associate this code with the click event.

So the WinForms framework monitors the messages that Windows sends to your form, and among these messages Windows warns that the user has clicked the button; hence the WinForms framework invokes the code you associated with the click of the button.

13.08.2015 / 18:25


Usually the term event-oriented programming is used.

In this paradigm the code execution flow is determined by triggered events, that is, some state changes and because of this a behavior is called to execute. The execution of the algorithms is conditional on something previous occurred.

It works with Hollywood principle , where you should not call anything, you must sign up to be called.

Common Uses

Events have their most common use in GUIs, but can be used in database, file systems, networking, operating system signals, specific hardware through #, or even commercial and scientific applications may have events in their objects.

In many cases events are triggered according to events that are being verified in a tie , in others there is only one inscription somewhere that should be called a part of the code when something happens.

Relation to OOP

She can work with OOP and even benefit from it, but not necessarily. They are orthogonal paradigms and have no relation. Events can be applied to objects, but only this. Any relationship is coincidence. One does not harm another, on the contrary, just they are more powerful.

In OOP, objects are communicating through simple methods of passing messages. In EDP this communication occurs through event notifications.

EDP does well with imperative, functional programming, etc.

Event-driven languages

I do not know any language that has this focus and I think it's just a very specific one, maybe a DSL can be. What exists are language that use this paradigm as a complement. C # is a clear one that has features in the language to handle events. VB.Net is another.

All languages, in one way or another, work with events, even if it does not look like it. This is not to say that they are event-driven. Some use this technique a lot, but they do not have anything specific in the language to handle events. They have a mechanism that makes it possible for you to create your events and manipulate them. Does this make event-driven language? I do not know, but I do not think so, otherwise it would be rare for language that is not event-driven. Any language that has a mechanism that allows you to treat functions as data can somehow work this way. And there must be other ways to get the same result.

Is JavaScript targeted to events? I may be wrong, but I do not think so. The DOM and the HTML itself seems like it, but the programming language does not seem to have anything specific to handle events. It has a generic mechanism that serves very well the purpose. Just this.

The paradigm is used throughout computing

However, you can create event-driven code even if the language does not provide resources. The schedule made in JS is clearly all event-driven. You can adopt language standards that meet the requirements of the paradigm.

Windows is all event-driven. Anyone who knows the Win32 API knows deep down your program is asking Windows if something relevant to that code happened.

13.08.2015 / 18:24