Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 language. )

share|improve this question
add comment

4 Answers

up vote 5 down vote accepted

Other than Jalayn's excellent answer I'd like to add:

Consider learning the Observer pattern

It is a Design Pattern used to implement event handling. If your programming language doesn't have first class support on delegates and events (see in Java how it solves with event handling in AWT and Swing) then you'll be implementing it using this pattern instead.

Note that Java has an Observer/Observable available in it's class library, but it is surprisingly simple to implement these yourself. In C# there are the IObserver/IObservable (that has some LINQ capabilities through Rx), but you can use delegates and events as well for the same purpose.

share|improve this answer
    
+1 Forgot the one I've just used yesterday! Also it is much easier to start with this than to start with the whole Swing API if one does not know it beforehand. –  Jalayn Jan 24 '12 at 9:27
    
@Jalayn: Yes, I can relate to that. By writing an observer/observable thing by myself on some other thing I just magically started to understand the Swing API. When I got into C# programming later, a friend told me that event handling is just an application of the Observer pattern and it all just fell into place with a big "A-HA" realization. –  Spoike Jan 24 '12 at 9:37
add comment

.NET/C#

If you're indifferent to languages, you may try it in C# (Visual Studio Express C# is free). C# has specific event and delegate keywords for event-drive programming, and it is quite easy to grasp the idea. It starts with how event listening works, and ends with how to write your own events. There is also an interesting, but a bit further advanced article, on how to implement event-based asynchronous patterns here.

Now, there is an MSDN tutorial to start you up with the basic idea.

Java/Swing

If you want to try it in Java, you may, while programming a Swing application. There is also an Oracle tutorial on that subject, more specifically the intro. Edit: check out @Spoike's answer about the Observable pattern.

Javascript/JQuery

It is more specific to how JQuery's handles events, but you may find Benson Wong's tutorial helpful. Also, you just need to download JQuery, and you're ready to try.

share|improve this answer
1  
I'd add Objective C/Cocoa to that list if you are on a Mac –  World Engineer Jan 24 '12 at 17:20
add comment

Though i wrote in a different context - here is a best compilation of resources to your query: What is the architecture model of an Android application?

Basically, learn various patterns from POSA and related literature from the same author.

Another good resource is here.

Also, if you are in C, consider using libevent. It shows how good scalability is achievable using such constructs.

share|improve this answer
add comment

Consider this an addendum to the real answers. But you could look into hardware interrupts on the hardware platform of your choice. Say, on an Arduino or some such micro-controller.

These are what drive event-driven programming. Higher level programmers don't usually interface with them directly, but it's good to know about the underlying hardware.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.