Event-driven programming refers to the programming technique where the flow of the program is driven by recognition and handling of events such as mouse clicks, key presses, etc.
43
votes
4answers
4k views
When should I use event-based programming?
I have been passing callbacks or just triggering the functions from other function in my programs to make things happen once tasks complete. When something finishes, I trigger the function directly:
...
40
votes
1answer
15k views
Communication between nested directives
There seem to be quite a few ways of communicating between directives. Say you have nested directives, where the inner directives must communicate something to the outer (e.g. it's been chosen by the ...
30
votes
6answers
1k views
How to handle initial state in an event-driven architecture?
In an event-driven architecture each component only acts when an event is sent through the system.
Imagine a hypothetical car with a brake pedal and a brake light.
The brake light turns on when it ...
22
votes
6answers
4k views
Is an event loop just a for/while loop with optimized polling?
I'm trying to understand what an event loop is. Often the explanation is that in the event loop, you do something until you're notified that an event occurred. You than handle the event and continue ...
17
votes
4answers
743 views
What should plugins use: hooks, events or something else?
Consider an app that allows plugins to react to its program flow.
I know 2 ways to achieve this: hooks and events
1. Hooks
Use calls to empty functions inside the main program flow. These functions ...
14
votes
6answers
5k views
Merits of a “Message Passing” system vs. an “Event Based” system
My question is coming from an somewhat uneducated perspective.
What are the relative merits of a "message passing" system vs an "event based" system.
Why would one choose one over the other? What ...
11
votes
2answers
557 views
How does event bubbling generally work and is it synonym to event propagation?
I'm trying to wrap my head around the general workings and principles of event dispatching in event-driven (sub-)systems.
Although I have used it on quite a few occasions in for instance Javascript, ...
10
votes
5answers
767 views
Is event chaining considered good practice?
From time to time I've encountered scenarios where several complex conditions need to be met prior to triggering an event. Furthermore, most listeners also run additional checks to determine the ...
10
votes
1answer
2k views
In general how do Event Handlers work?
This is a general topic, How do Event Handlers work?
This means behind the scenes - what happens when they are created.
I have a rough idea - but would like to have it confirmed.
9
votes
6answers
2k views
How to ease the maintenance of event driven code?
When using an event based component I often feel some pain at maintenance phase.
Since the executed code is all split around it can be quite hard to figure what will be all the code part that will ...
9
votes
1answer
560 views
Futures/Monads vs Events
In an application framework
when performance impact can be ignored (10-20 events per second at max),
what is more maintainable and flexible to use as a preferred medium for communication between ...
8
votes
2answers
701 views
How to detect achievements in gaming?
I mistakenly posted this to stackoverflow and now posting here based on a suggestion in on that site ...
This is a very high level conceptual question. Say in a software application I have 4 ...
7
votes
6answers
3k views
Triggering custom events in AJAX callbacks
I'm pretty new to JavaScript, but one of the things that's been frustrating is that our AJAX callbacks have been getting packed with different functionality, making it difficult to keep everything ...
6
votes
2answers
398 views
How is the publish-subscribe pattern different from gotos?
My understanding is that Goto statements are generally frowned upon. But the publish-subscribe pattern seems to be conceptually similar in that when a piece of code publishes a message, it performs a ...
6
votes
2answers
787 views
Is it true that websites don't need to use an event driven framework given the stateless nature of the web?
I feel like it's critical to use an event driven architecture with a lot of application types that aren't web sites. However, when coding web sites(which are stateless at the most basic level) it ...
5
votes
1answer
8k views
What is the difference between routed events and attached events?
I am just going through the WPF concepts I came across these routed events, dependency properties and attached events.
What are the concepts behind them and why are they called instead of .NET ...
5
votes
4answers
2k views
Learning event driven programming [closed]
I want to learn more about event driven programming. Especially where and why I would consider using events. What resources/books should I consider reading to this end? (note: I'm indifferent to ...
5
votes
2answers
2k views
Event Driven Programming: A sequence of unfortunate events
I have a very basic game loop whose primary purpose is to check for updates & changes to a list.
I have contemplated using event driven programming to replace the game loop/list idea with an ...
5
votes
1answer
2k views
Which notification pattern is preferable?
I'm working on a view model for a view that presents a dialog with export options. The user selects options then clicks Export. When the view model completes the Export, the calling view model ...
5
votes
3answers
561 views
How to document events?
Code documentation is usually related to a piece of code, be it small (method-level) or larger (class- or namespace-level). However, it is always about the inputs and the outputs of that piece of ...
4
votes
2answers
365 views
Should an event listener be called if attached after the event has already fired?
Should an event listener be called if it is attached after the event has already fired? What if the event will only be fired once?
The first example that comes to mind is the ready event in jQuery. ...
4
votes
3answers
1k views
Combining multiple events into one action/ Defer refreshing
So in a GUI program I have multiple events that trigger a update of a workspace. This update call is costly so I would want it to not happen very often.
A user might pick something from a dropdown ( ...
4
votes
2answers
442 views
How to name event types?
Clean code recommends to name methods to be a verb, and classes to be a noun.
I am developing an c++ application using boost::signal as some kind of event framework, and have defined various events, ...
4
votes
1answer
1k views
Why are wrapper classes not suited for use in callback frameworks?
I just read the question what are callback frameworks?, where the asker cites the following from Effective Java:
The disadvantages of wrapper classes are few. One caveat is that
wrapper classes ...
4
votes
2answers
192 views
Does it makes sense to implement an event dispatching system that allows event bubbling for non GUI related objects?
Following up on this question of mine, where I wanted to know the general principles of implementing an event dispatching system that allows for events to bubble (and capturing I've come to learn); ...
4
votes
1answer
828 views
Need to process 2 million 100k messages per second and route them to a particular event, delegate or multicast delegate
I need to process 2 million messages per second (perhaps in a scale out configuration) and route each message to a N delegates or multicast delegates.
Question
How should I structure my application ...
4
votes
1answer
97 views
Is it better to put an event on the top object or closer to where it's local?
Take the following basic structured code for example:
class Player
{
public QuestLog QuestLog { get; set; }
}
Let us consider that "QuestLog" has the ability to fire off some events when things ...
3
votes
2answers
883 views
Thread safe GUI programming
I have been programming Java with swing for a couple of years now, and always accepted that GUI interactions had to happen on the Event Dispatch Thread. I recently started to use GTK+ for C ...
3
votes
1answer
114 views
Structure project based on platform or design?
I have a medium sized project (~10,000 lines) that runs on Windows and Linux. However it is only specific components of the program that are platform dependent and are located in a folder called ...
3
votes
1answer
353 views
Are there any design pattern to data binding in event driven architecture?
I develop a browser based game with node.js in back and HTML5 canvas in front-end.
It use WebSockets for communication.
My plan is to generate business events in client side, e.g.: "finishJob".
...
3
votes
1answer
283 views
Should Libraries Use Events or a Set Action
I'm building a small reusable library for two systems our company manages.
Something that I've been caught up on is whether I should expose a set of properties of type Action<T> for events such ...
3
votes
2answers
129 views
Attaching Events to Document Better Than Attaching Them to Elements?
While bouncing around StackOverflow, I've noticed a number of people attaching events (notably click events) to the document as opposed to the elements themselves.
Example:
Given this:
<button ...
3
votes
1answer
105 views
Assessing Relative Maintainability
We (a contractor, actually) are implementing an off the shelf system to replace a legacy homegrown system for the core domain of the company (designing widgets). Unfortunately both systems will have ...
3
votes
1answer
568 views
Push-Based Events in a Services Oriented Architecture
I have come to a point, in building a services oriented architecture (on top of Thrift), that I need to expose events and allow listeners.
My initial thought was, "create an EventService" to handle ...
3
votes
1answer
80 views
Event system architecture for networking when performance is concerned
How should I design a system for an action game (think in Golden Axe) where events can happen remotely?
I'm using TCP for this because the client is in flash.
There's so many options, I can make a ...
3
votes
0answers
95 views
Web framework architecture with non-blocking I/O
There's been a lot of news in the enterprise world lately, specially in the web, and I've decided to build a small web framework on top of Netty to learn more about asynchronous programming and ...
2
votes
3answers
165 views
Are imperative events an anti-pattern?
Are events which are intended to tell listeners to carry out explicit actions an anti-pattern?
Imagine a worker service which raises the event WorkStarted at its beginning and the event WorkFinised ...
2
votes
3answers
1k views
jQuery - When to Bind Event Listeners?
I'm building a medium-sized "single-page" JavaScript application using jQuery. If you include all possible functionality of the application, there are 134 click bindings.
Since most of the content is ...
2
votes
3answers
2k views
Difference between event loop and system calls/interrupts
When you create programs (like a socket server) that are designed to run on an operating system, such as Ubuntu, frameworks like Qt for C++ use something called a main event loop:
app = new ...
2
votes
1answer
341 views
Application protocols and state machines: designing a complicated server
I'm designing and prototyping a server that has the following characteristics:
during the daemon's initialization it spawns nine "manager" servers, each of which solves one part of the overall ...
2
votes
1answer
89 views
What are the underlying patterns in systems allowing asynchronous operations?
Say I'm working with a system that allows async, nonblocking operations. If I queue up a set of those operations and specify their result buffer references:
nonblocking_write( message, write_buffer ...
2
votes
2answers
311 views
What are the caveats of the event system built on Messenger rather than on classic .NET events?
MVVM Light and PRISM offer messenger to implement event system.
the approximate interface looks like the following one:
interface Messanger
{
void ...
2
votes
1answer
1k views
Global vs Individual object event handlers
Lately I've been studying a lot of javascript samples, both with/without libraries, jQuery to mention one.
As an old JavaScript developer, I learned early to make use of unobtrusive javascript where ...
2
votes
2answers
331 views
In an event-driven environment, how should a “cancel” function abort all further events?
In my iOS app, things are mostly driven by events.
The user presses a button
The app listens for an external device to be connected to the iOS device
Once the device is detected (is connected), an ...
2
votes
1answer
19 views
Identity propagation using Azure service bus
We currently have a platform with a SOA architecture in which the user's identity is propagated from the web application via middle tier services (REST and SOAP) until we actually query our data ...
2
votes
1answer
209 views
Why do browsers clamp timeouts and intervals?
I've been working on some abstractions of setTimeout and setInterval in order to process large sets of data without blocking the event loop in the browser.
Upon this, I have discovered that browsers ...
2
votes
1answer
221 views
Do I need EventAggregator here?
I'm learning MVVM pattern with C#, WPF and .NET Framework 4.5.1.
I'm using MVVM Light framework to do it and now I have a doubt. Reading the book Windows 8 MVVM Patterns Revealed I see that the ...
2
votes
2answers
168 views
Distribution of Event Listeners in a Distributed Service Oriented Architecture
I have a service architecture composed of services that service common areas of the application. Examples of services would be:
AccountService (manages client accounts in the system)
BillingService ...
2
votes
0answers
47 views
Multiple handlers of an exception, and handling exceptions in the UI
Related to: Is onError handler better than exceptions?
Premise
I am writing a piece of library code that performs certain tasks, to separate concerns, we decided it should not write to a log or ...
2
votes
0answers
203 views
State Pattern Code for embedded device - Dependency Injection of Device Objects in Context and State Classes
I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events.
I've got a simplified system that will work like this:
This is my first go with State ...