General and Web Programming Fundamentals
  • Introduction
  • Program creation and design
    • Program design
      • Algorithms
      • Pseudocode
    • Programming conventions
    • Writing programs
      • Source code editors
      • Integrated Development Environments
      • Code repositories/Version control
      • Compilers/Interpreters
  • Programming Fundamentals
    • Operators
      • Arithmetic
      • Logical
      • Assignment
    • Constants and Variables
    • Datatypes
      • Primitive Datatypes
        • Character
        • Integer
        • Boolean
        • Floating point
        • Nothing (Null)
      • Composite Datatypes
        • Arrays
        • Strings
        • Classes
        • Structs
      • Literals
    • Data structures
      • Lists
      • Queues
      • Stacks
      • Map/dictionary
      • Trees
      • Graphs
    • Control structures
      • Selection (Conditional)
        • If/Else
        • Ternary
        • Switch
      • Iteration (Loops)
        • For loops
        • While loops
        • Do-While loops
        • For-Each loops
    • Functions
      • Parameters and arguments
      • Lambda expressions
      • Higher Order Functions
    • Space and Time
    • Scope
    • Standard libraries
  • Programming Paradigms
    • Procedural (Imperative) Programming
    • Object-oriented programming
    • Functional Programming
    • Declarative Programming
    • Event Driven programming
  • Programming Languages
    • Short history of programming
    • Low-level programming languages
    • High-level programming languages
  • Web Development
    • What is the web?
      • Web browsers (clients)
      • Webservers (serving web pages)
      • W3C
    • Markup languages
      • HTML
        • HTML Tags
      • Cascading Style Sheets (CSS)
        • CSS Properties
      • XML
      • Markdown
    • Scripting Languages
      • JavaScript
      • TypeScript
    • JSON
    • JavaScript Frameworks
  • Acknowledgements
    • About the author(s)
  • License
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Programming Paradigms

Event Driven programming

Event-Driven Programming Paradigm

Event-Driven Programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or message passing from other programs or threads. This paradigm is widely used in developing applications with graphical user interfaces (GUIs), real-time systems, and other systems that need to respond to changes in the external environment or user inputs efficiently.

Key Concepts of Event-Driven Programming:

  • Events: Actions or occurrences detected by the program that may trigger a response. They can come from various sources like a user interaction, hardware signals, or software messages.

  • Event Handlers: Functions or methods that are executed in response to an event. Each handler is associated with a specific event and defines the program's reaction to that event.

  • Event Loop: A control structure that listens for events and dispatches them to their corresponding handlers. An event loop keeps running, waiting for events and handling them as they occur.

  • Listeners: Components or objects that register to be notified when a specific event occurs. They 'listen' for an event and execute an event handler when the event is detected.

Advantages:

  • Asynchronous Execution: Allows programs to be more responsive by performing operations asynchronously and responding to events as they happen.

  • Loose Coupling: The components of an event-driven system can operate independently, which enhances modularity and makes the system more scalable and easier to modify.

  • Efficiency: In IO-bound and GUI applications, it can be more efficient as the system spends less time waiting and can quickly react to inputs or changes.

Disadvantages:

  • Complexity: Managing and debugging event-driven programs can become challenging, especially in systems with many events and handlers.

  • Unpredictable Execution Order: Since the execution order depends on the occurrence of events, it can be unpredictable and may lead to issues if not carefully managed.

Event-driven programming is a powerful paradigm that enables developers to create interactive, responsive programs. It is particularly suitable for environments where the system needs to react to external or internal events efficiently and in a non-linear fashion.

PreviousDeclarative ProgrammingNextProgramming Languages

Last updated 1 year ago

Was this helpful?