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.

learn more… | top users | synonyms

0
votes
0answers
75 views

Advantages of Event Sourcing over history tables [closed]

I'd like to use Event sourcing pattern in my application but I can't decide if it has so many benefits. As I read in many articles, the main benefit is that I have all events on my entities that ...
-1
votes
0answers
23 views

Multiple publishers to one subscriber: handling subscribing and unsubscribing [migrated]

I hope this isn't too general, so I apologize in advance if so. I am creating a console text adventure game. I essentially have many monsters, one per room at the moment. I also have a God ...
6
votes
2answers
385 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 ...
0
votes
2answers
101 views

What's the simplest way to deal with events in C in this situation?

I'm writing a text-based game, in C. I want the game to handle NPCs movement and actions in the background, while the user is making his moves. I'd also use time-based events to tell the user when ...
5
votes
3answers
521 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 ...
2
votes
1answer
86 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 ...
1
vote
3answers
73 views

When is a event listener invoked during program execution?

I am using the Obervable-Observer Pattern. MyClass extends Observable{ invokeListeners(){ doSomething; setChanged(); notifyListeners();//This invokes onUpdate() in "implements ...
41
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: ...
0
votes
2answers
2k views

Event Driven Programming? [duplicate]

I have been looking into event driven programming in C and the language doesn't seem to have support for it. This has led me to wonder about the nature of event driven programming. Is it correct to ...
2
votes
2answers
119 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 ...
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.
1
vote
1answer
198 views

Should I use: One event multiple subscribers or multiple events multiple subscribers

I am writing a data acquisition application. I wondering whether I should use one event multiple subscribers or multiple events multiple subscribers. I am worried about performance. Also could I ...
0
votes
2answers
78 views

Receive events in an event-loop, single-threaded

Let's say I have a program which consists of a main event loop. The event loop should check for tasks and if one exists, it is to be processed. The user interface consists of a GUI with buttons, for ...
37
votes
1answer
14k 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 ...
3
votes
1answer
103 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 ...
1
vote
2answers
188 views

Observer pattern without state change?

My question is whether there is a similar pattern to Observer that does not imply a state change in the observed object. The following is a concrete example: I have a ConnectionFactory class which is ...
1
vote
1answer
82 views

Event action abstraction and trigger control

I am thinking of abstracting Event action in order to make further alteration/implementation/maintenance easy since the project I am currently working on has volatile requirement. So I thought of the ...
1
vote
1answer
128 views

Software to access GSM Terminal, sending and receiving AT commands, validating results

I am currently implementing a software that uses a GSM terminal to perform actions. Actions can be sending messages, checking balance, receiving status report messages, setting the pin, ... 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 ...
2
votes
1answer
193 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
275 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". ...
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 ...
0
votes
3answers
106 views

Event Driven Objects/Framework on the Web [closed]

I am a desktop developer moving to web development. The guys who I am working with use procedural PHP, and coming from an event driven, objectified perspective (using WPF and C#.Net) I am completely ...
1
vote
1answer
74 views

Compose nested EventEmitters elegantly

I am developing a server-side JavaScript tool, and trying to do so in a modular way. I have a Parser class that is an EventEmitter - you call parse and it will eventually emit data and end events. It ...
3
votes
1answer
531 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 ...
1
vote
2answers
112 views

Separate methods or single method with if statement?

I'm working on a .NET application and I'm wondering if I should use separate methods to handle the click events of two different buttons. They essentially do the same thing, just on different objects ...
4
votes
2answers
322 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. ...
1
vote
0answers
17 views

Hidden event handlers and their parameters

I'm having a bit of trouble understanding why has an event handler to be defined as a function. AFAIK, a function can be used as anonymous called procedure as event handler It defines a ...
-1
votes
1answer
64 views

How do Event Bus and ReativeX interact with each other?

I wanted to look into communication/decoupling patterns and how to improve them. My current approach is to have a centralized commander in the form of an Event Bus and make him be the one to respond ...
1
vote
1answer
315 views

Pass Event between Systems in a multi-threaded Entity-Component-System

Is there a way to pass Events between Systems in a multi-threaded Entity-Component-System that realizes the benefits of saving on system resources? I've read a german article about the ...
2
votes
1answer
195 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 ...
0
votes
3answers
137 views

Are EventHandler<T> and IObservable<T> interchangable?

I have an object which will periodically raise an event based on an action performed in an application. This will be heard by any listener(s) and acted upon accordingly. I do not wish to use a ...
-1
votes
2answers
147 views

Deeper understanding of event loops and timers [closed]

I have a basic grasp of accepting clients without creating a thread for each connection using tools such as select and modern equivalents (kqueue, epoll). But where do I go from here? e.g async I/O ...
4
votes
1answer
95 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 ...
0
votes
1answer
97 views

Pattern that prevents events to trigger themselves

I am working at the client-side part of a web application, that is responsible for getting answers from users for specific questions and storing and restoring them from the database (or cookies) and I ...
2
votes
0answers
45 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 ...
1
vote
0answers
871 views

Updating GUI in 'realtime' using events

My Plan Have a system that holds some objects Have a winforms-form that displays some key values of these objects When certain changes occur(object gets add / removed / datat change): Update GUI ...
1
vote
0answers
44 views

Is there just one EventHandler class per application?

In a game I'm making I was about to add a MovementEventHandler, with events like "pre-character-movement" and "post-character-movement". But this class will do exactly the same as a future ...
17
votes
4answers
703 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 ...
1
vote
1answer
433 views

Should I omit the parameter “e” when using EventHandler<EventArgs>?

Whenever I am defining my own events, I use a pattern such as the following (which I believe is how the MSDN recommends doing it): public class MyEventClass { private bool _value; // Backing ...
2
votes
3answers
910 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 ...
1
vote
1answer
184 views

Good pattern(s) for pointing to mutable state

I asked this question once here, but believe the question was unclear. However I'm having a hard time extracting the general problem from my specific case. UPDATE: I've answered my own question ...
0
votes
3answers
82 views

One Event Sent to Multiple Listeners, Want to Log Notification Once

I have a system in place where a Cache is made up of many Cache Nodes. When one is added, a CacheNodeAdded event is raised by the Cache. The Cache has a redundant set of Monitors listening for ...
2
votes
0answers
184 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 ...
0
votes
3answers
328 views

When/Where to create/assign event handlers to its elements

Lets say I have the following code // JS $(function(){ $('[data-mc=logout]').click(function(){ if (!confirm(myconfig.msg['asklogout'])) { return false; ...
10
votes
5answers
705 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 ...
3
votes
1answer
267 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 ...
1
vote
1answer
978 views

How does jQuery's mechanism of event handlers work

I'm in the need of widen my perspective on the framework libraries, to be able to make well aware choices of if/which/when to add a framework to a website. One thing that got my attention was event ...
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 ...
1
vote
2answers
316 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 ...