Skip to content

Commit

Permalink
docs: improve hooks framework reference
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi authored Oct 28, 2024
1 parent e8dadec commit 77cb349
Showing 1 changed file with 37 additions and 22 deletions.
59 changes: 37 additions & 22 deletions docs/concepts/hooks-extension-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,56 @@ Hooks Extension Framework
Overview
--------

To sustain the growth of the Open edX ecosystem, the business rules of the
platform must be open for extension following the open-closed principle. This
framework allows developers to do just that without needing to fork and modify
Open edX platform.
Based on the `open-closed principle`_, this framework aims to extend the platform in a maintainable way without modifying its core. The main goal is to leverage the existing extension capabilities provided by the plugin architecture, allowing developers to implement new features to fit customer needs while reducing the need for core modifications and minimizing maintenance efforts.

Hooks: Open edX Events and Filters
----------------------------------

Hooks are predefined places in the Open edX project core where externally defined
functions can take place. These functions may alter what the user
sees or experiences on the platform, while in other cases, they are purely informative. All
hooks are designed to be extended through Open edX plugins and configurations.
Hooks are a list of places in the Open edX platform where externally defined functions can take place. These functions may alter what the user sees or experiences on the platform, while in other cases, they are purely informative. All hooks are designed to be extended through Open edX plugins and configurations.

Hooks can be of two types, events and filters. Events are, in essence, signals
sent in specific places whose listeners can extend functionality. While filters
are functions that can modify the behavior of the application.
Hooks can be of two types: events and filters. Events are signals sent in specific places whose receivers can extend functionality, while filters are functions that can modify the application's behavior.

To allow extension developers to use the framework's definitions in their
implementations, both kinds of hooks are defined in lightweight external
libraries:
To allow extension developers to use the framework's definitions in their implementations, both kinds of hooks are defined in lightweight external libraries:

* `openedx-filters`_
* `openedx-events`_

The main goal of the framework is that developers can use them to change the
functionality of the platform as needed and still be able to migrate to newer
open releases with very little to no development effort, so they're designed
with stability in mind, meaning that they are versioned and backward compatible
as much as possible. In the case of the events, this approach is further
detailed in the `versioning ADR`_ and the `payload ADR`_.
The main goal of the framework is that developers can use it to change the platform's functionality as needed and still migrate to newer Open edX releases with little to no development effort. So, the framework is designed with stability in mind, meaning it is versioned and backward compatible as much as possible.

A longer description of the framework and its history can be found in `OEP 50`_.

Why use Open edX Hooks?
--------------------------------------

#. Stable and Maintainable Extensions

The Hooks Extension Framework allows developers to extend the platform's functionality in a stable, maintainable, and decoupled way ensuring easier upgrades and long-term stability by removing the need to modify the core in an significant way.

#. Contained Solution Implementation

By avoiding core modifications, the framework promotes self-contained solutions, eliminating the need for custom code to coexist with core logic which lowers maintenance costs for extension developers.

#. Leveraging the Open edX Plugin Extension Mechanism

The framework allows developers to implement custom business logic and integrations directly in plugins. This keeps core modifications minimal, focusing maintenance and development efforts on plugins, where solutions can be built and maintained independently of the core platform.

#. Standardization

Both filters and events implementations implement an approach for adding additional features, such as communication between components or services, or backend flow control. With these standards in place, it’s easy to identify when and how to use the framework as a solution, ensuring a consistent and predictable approach to extending the platform.

#. Reduce Fork Modifications

The need to modify logic in forks is minimized, as most extensions can now be implementing using the framework, keeping forks closer to the core and easier to manage.

#. Community Compatibility

The framework allows for shorter and more agile contribution cycles. By adding standardized extension points, contributors avoid creating customer-specific logic, making development more community-friendly.

#. Backward Compatibility

Hooks are designed to be backward compatible, guaranteeing stability across releases and making it easier to upgrade without breaking existing functionality.

.. _OEP 50: https://open-edx-proposals.readthedocs.io/en/latest/oep-0050-hooks-extension-framework.html
.. _versioning ADR: https://github.com/eduNEXT/openedx-events/blob/main/docs/decisions/0002-events-naming-and-versioning.rst
.. _payload ADR: https://github.com/eduNEXT/openedx-events/blob/main/docs/decisions/0003-events-payload.rst
.. _openedx-filters: https://github.com/eduNEXT/openedx-filters
.. _openedx-events: https://github.com/eduNEXT/openedx-events
.. _open-closed principle: https://docs.openedx.org/projects/edx-platform/en/open-release-quince.master/concepts/extension_points.html

0 comments on commit 77cb349

Please sign in to comment.