Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event driven vs sequential programming [closed]

One of my friend recently had an argument in his team about the pros and cons of event driven programming vs sequential programming.

What are your views about it?

like image 746
sachin Avatar asked Dec 03 '09 08:12

sachin


People also ask

What is the difference between a sequential and an event driven program?

In sequential programming each command is run many times in sequence. In event-driven programming all commands are run a single time as an event. In sequential programming commands run in the order they are written. In event-driven programming some commands run in response to user interactions or other events.

What is a sequential driven program?

A sequential program explicitly waits in-line, for the expected events in various places in the execution path. This explicit waiting for events is implemented either by busy-polling or blocking on a time-delay, a semaphore or other such mechanism of a traditional Real-Time Operating System (RTOS).

What is the opposite of event-driven programming?

The opposite of event-driven programming would be software that doesn't need any user input to act. This also covers the case of having various services poll each other for data in timed intervals instead of being triggered by events.

How does event-driven programming differ from other programming approaches?

The main difference between event-driven programming and other forms is in how you receive input. With an event-driven approach, much of your code is bundled into event handlers that sit around waiting for the event source to collect the data of an event and notify all handlers.


1 Answers

Two different methods to support two different needs. If you have a problem driven by events, then you should use an event-driven methodology. If you need to perform procedures on defined data, but you're not worried about what's happening elsewhere, then obviously you want to use a more "sequential" style.

Note that typically, these two things are combined. A program's startup, shutdown, and maybe a main processing loop (say, a filter processor in an image app) will be largely sequential, while its UI layer and component interactions are event-driven.

like image 119
phoebus Avatar answered Oct 25 '22 20:10

phoebus