What is an event?

9

Much is heard about events:

  • Shoot events;
  • Schedule events;
  • Trigger events ...

Although much is found on the internet, none brings a concrete definition of what a programming event really is. So what is a programming event for what they serve and where they are used?

    
asked by anonymous 25.05.2017 / 21:25

2 answers

9
  

In computing, an event is an action or occurrence recognized by software that may be handled by the software

So according to Wikipedia is an action or occurrence recognized by the application that needs to be handled by that application.

Being more direct is an event, something that has changed state, or performed something that should determine a possible other unrelated action directly. An event can be generated by hardware or some software component, including its own application.

The event, in the context it seems to ask, is the whole mechanism that allows you to notify other areas of the application that want to know that something specific has happened.

Examples

An event is a keystroke, a movement of a mouse, a joystick button, a data entry into the microphone, scanner , network, installation of some device, a service notification, relevant operating system information that needs to be handled immediately, an API event such as GUI, database, file system (a file was created, modified, deleted, accessed, etc.). ) or web service such as GitHub to inform you that there has been a commit , or in your application where the bank account needs to be notified when a deposit is made, or a customer makes a purchase greater than a value . It's full of examples in the other linked questions here.

Every GUI system is one of the greatest examples. In Windows everything that occurs that your application should know is sent a message telling it what happened to the application to decide what to do. This is an event, although it does not usually carry this name, even by not adopting the specific paradigm.

Recently caught fashion serving HTTP by events (Nginx, Node.js are best known, but almost all stacks do this now). The advantage of this is that the application does not wait for something to happen, it responds to the need when the event is triggered.

The event is a very simple mechanism indeed, but with powerful results. This can be seen in more detail in links below.

Learn more about event-oriented programming .

Events are a way to implement the default Observer .

About the event handlers .

See also Listeners are an implementation of Observer? .

    
25.05.2017 / 21:38
2

"Event" is usually the same as function or procedure, that is, they are code blocks with specific goals. What happens is that the term event is more related to parts of the application than there will be external iteration (human or not) firing this event.

This is very clear in applications that have interface building, such as visual basic, where you have the components (button for example) and this button has the "click event" button.

    
25.05.2017 / 21:49