Components, Modules, Plugins, Packages and Widgets – Which is which and what’s the difference

Above. Node only has one Zombie package but lots of bacon. Dear Industry, You’re confused. Different platforms adopt their own definition of these terms. Joomla uses ‘Module’ to describe dynamic elements which can be assigned to template positions. WordPress calls this a ‘Widget’ and October CMS calls this a ‘component’. In Drupal, a package which extends the functionality of the application is called a Module, which Joomla would call a ‘component’. And the Drupal equivalent of a Widget? A “block” of course. This confusion doesn’t stop within web applications it extends throughout the entire software industry. COM programmers think that a component is basically a class, some Java programmers expect components to be interface related, .net has its own special type of component executable, PHP programmers have 5 different definitions and node programs talk in modules only…. So, with all this confusion over which is which loitering around, is there an actual definition we can look to for some answers? During my quest to shed some light, I tackled Component vs Module definitions first.

The Tough One

Although I have been using both, in one form or another for over a decade, defining the difference between a component and a module is especially tough. They are both, essentially, just abstract terms for encapsulated groupings of code. After a few days of surfing (see some of the sites I viewed at the bottom of the article), reading various definitions and asking around, the best I can really say is that a component is normally a more granular and more “black boxed” encapsulation than a module. Below I’ve listed the characteristics I would expect to see from each based on my experience and research. And hope to use these moving forward to derive my personal definitions.

Module

  • Medium granularity.
  • A sub-system of an application which adds functionality to an application.
  • Responsible for its own asks / area.
  • Communicates with other modules within the larger application.
  • Potentially looser internal cohesion than a component.
  • Potentially looser encapsulation than a component.
  • Potentially utilises components.
  • Should contain everything needed to manage one sub section of the application independently from other modules.
Example: Networking Module, Hardware Interface Module, User Signup Interface.

Component

  • High granularity.
  • Might not directly add functionality to a larger application but provides useful functions to the application e.g. a HTTP library component.
  • A “black box” grouping of code into an encapsulated package with a clear, limited interface.
  • High internal cohesion.
  • Deals with a specific function or closely related group of functions.
  • Composed together with other components into larger sub-systems (modules) or applications.
Examples: HTTP Component, Framework Library, XML Parser, DLL, External Web Service. Outside of pure OOD, ‘component’ may also refer to other encapsulated stuff such as a web service, resource, or even a hardware node such as a robot or tool. Both components and modules are generally expected to be encapsulated and compatible with others and support independent deployment and versioning as packages.

I Think Node Is Right.

In Node JS a module is built up of multiple building blocks. Normally the building blocks are “black-box” classes and supporting information in their own files, exposed via ‘module.export’. This is a good example of a modular structure, with modules made up of small components. In my humble opinion, Node JS is generally correct in terms of its naming of these design abstractions, but as with all grey areas, there are a lot of places where definitions overlap and modules could be considered components or vice versa. OK, now that I’ve (kind of) dealt with Components and Modules, time to move on….

Package

  • A software package is any component, module, application or auxiliary asset which is packaged up for distribution.
  • Packages are distributed with version management.
  • Packages will often come with supporting information like user guides, documentation etc.
Good examples are:
  • Modules packaged up for the Node Package Manager (NPM) with their JSON package files.
  • PHP components packaged with Composer with their JSON package config files.
  • An executable installer for something like the amazing game Skyrim which installs a complete packaged application on your machine.

Plugin

Oh crap. This one is basically like a module again. At a high level, a plugin could be described as a package which provides add-on functionality, which easily plugs in to an existing application. It sounds similar to a module, but there are some defining differences which make it quite distinct:
  • A plugin normally registers itself with a service provided by the main application framework. In this way the plugin can be ‘called’ at a specified point during the execution stream of the application.
  • This is often done using event hooks, so for example a plugin may register functionality which is executed right before the application renders an interface, or perhaps just after. This might look like:
public function onBeforeInterfaceRender(FwInterfaceContext $context) { // Do Plugin Functionality Stuff e.g. Replace all instances of ".net" with "PHP" }
  • While a component or module may be portable to other applications and possibly usable on their own, a plugin depends on the ‘host’ application to function.
  • Plugins usually have a small set of ‘abilities’, or responsibilities, they often perform a task as small as outputting a message at the right time or replacing a bit of text.

Widget

Widgets are pretty easy to understand:
  • Widgets are normally associated with interfaces.
  • They are easy to use, portable UI components in many cases e.g. Facebook / Twitter widget.
  • Often they may be third party widgets integrated into your application’s interface.
  • Internally they will often be small components used to place dynamic elements in your interface e.g. WordPress search bar widget.
I hope this has helped clarify what the difference between components, modules, packages, plugins and widgets are. Please let me know your thoughts below, and thanks for reading. Research directions in software architecture Component and Module difference Software composition using “components” – Clarification needed In a software project, how would you differentiate a Component from a Module? Is there a difference between a component and a module