tags:

views:

709

answers:

4
+2  Q: 

What is a handler

Hi I am trying to learn some programing related terms, and I often comes over the word handler. Can anyone pleas explain what handler means and when to use the term.

Thanks in advance

t

A: 

Have you tried google and wikipedia?

In any case, a handler usually refers to some code that exists to handle an event - it will be called only when the event occurs.

Marcin
+10  A: 

A handler is a routine/function/method which is specialized in a certain type of data or focused on certain special tasks.

Examples:

Event handler - Receives and digests events and signals from the surrounding system (e.g. OS or GUI).

Memory handler - Performs certain special tasks on memory.

File input handler - A function receiving file input and performing special tasks on the data, all depending on context ofc.

Regards

/Robert

sharkin
Signal handlers - for handling signal 'events'.
Jonathan Leffler
A: 

I think it's a very general term, without a 'hard' definition. The meaning is highly contextual, varies depending on the general code design.

For me, it usually means some code that is called from an inner core and is supposed to do some things and return. That 'inner' part can have several 'handlers' available, and chooses which one to call.

In some cases, you define some API to make those handlers mostly interchangeable, so the caller can pick one from a table and use the same code to call any of them. OOP helps a lot here.

Javier
A: 

Code that's associated with and triggered by the occurrence of a specific event, like an incoming message, a thrown exception, a signal sent to a process, a network I/O request completing, or a mouse click on a user interface element. It's a very generic term.

Andrew