Examples of Modularity
This is a high-level review to help understand how different systems support add-on modules or plug-ins. This is not meant to be a programming guide.
A Joomla module is a combination of an XML file and a PHP file. The PHP file is a PHP code fragment enclosed. The XML defines the module, meta data about the module such as its name and author, and its parameters. They are uploaded into Joomla and then associated with a position on the Joomla template. The Joomla template is a full web page in PHP and uses the mosLoadModules command to define where a position is on that page. Where the mosLoadModules is called for a position name, Joomla renders the modules at that position.
In WordPress, you would upload your plug-in into a plug-ins directory. Then, you can go to the plug-ins menu in Word press and activate your plug-in in there. The metadata for your plug-in is defined in a comment block at the top of its PHP file. WordPress provides hooks for your plug-in to interact with WordPress: You can obtain the title and content of blog posts, filter the posts, or perform actions when other actions happen. A widget can be registered with WordPress on the sidebar and then associated with an action. For both widgets and plug-ins, you would write your logic as a function and pass it to WordPress.
Magento seems to use a page templating scheme similar to Joomla. You define something called a "block", and your template lays out where the blocks appear on a page. When you write a custom module for Magento, you have XML configuration files, a PHP controller file (Magento is object-oriented and uses a controller class), and a layout for your module.
To build an application to run in Facebook, you would host an application on your server, then interact with Facebook through a Facebook library you download. Your application loads the library, instantiates a Facebook object, and then sends your output back to Facebook as HTML. Your application needs to use an API key combination to communicate with Facebook, and you would register a "vanity" facebook application URL to mask your real server's URL. See How to Write a Facebook Application in 5 Minutes, User authorization for facebook, and Facebook Signed Request.
Salesforce.com gives you the ability to define new data objects and their relationships and then automatically generates screens and forms for them. You can also define security and triggers for your data objects. You can then add the screens to your application as a "tab." Thus, a simple application could be created without programming. See Salesforce Native Functionality
Salesforce.com also has the Apex programming language for more complex application. This appears to be database triggers but in Java-like syntax, with objects such as Lead, Email, etc.
Eclipse has a plug-in architecture based on osgi. Each plug-in is a bundle, which includes XML files, Java files, HTML, etc. This seems to be a standardized way of doing what the other open source projects, namely Joomla, Magento, and WordPress do. See How to write your own Eclipse plug-ins
This is a good tutorial on Java Portlets