Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a handler? [closed]

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 of course.


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.


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.