[blog] Welcome to the Drupal7 demo by Webel IT Australia

In the age old tradition, this site progressively records aspects of Drupal7 that may be of use to other Drupal7 developers, however it does so using full object-orientation and graphical Unified Modeling Language (UML). It is not, and will never be, a complete guide to Drupal7. It is offered in the hope that it may be of some use to others.

About the Webel IT Australia demo for Drupal7

This educational site demonstrates selected features and capabilities of the version 7 series of the PHP-driven Drupal Content Management System (CMS). It is by an experienced Drupal developer for other Drupal developers, with an emphasis on encapsulating Drupal7 core using an object-oriented bridge demonstrated through an object-oriented tutorial module OOE = Object Oriented Examples = One Of Each with graphical Unified Modeling Language (UML) models.

[blog] There is now a similar Drupal8 assessment and information site for other Drupal developers

Webel IT now also offers a similar site for Drupal8, with a focus so far on realistic assessment of progress towards production-readiness of Drupal8 core and contributed modules. It already contains a wealth of information and references on changes between Drupal7 and Drupal8 (such as the new Twig templating system and other Symfony related technology integration). Visit: https://drupal8info.webel.com.au.

Q: How is this site different from other Drupal7 demos ?

A: It is object-oriented with graphical UML support !

There are many Drupal7 demonstration sites; this one supplements those sites and distinguishes itself from them in the following crucial and unique ways, as explained by this slideshow:

This site progressively includes UML analysis diagrams to illustrate encapsulation of the Drupal7 module development system in truly OO form, which will hopefully encourage further adoption of OOP in future versions of Drupal core and in the contributed module development community.

This site uses an overtly "self-referential" educational strategy to expose Drupal concepts to developers, rather than being based on contrived examples. For example, a contributed module menu link in a block might be called "A contributed module menu link in a block" and would appear in a block. The demonstration panels page is simply called Demo: Panels page, it does not pretend to be a panels page for a fictional online lolly shop.

The author Dr Darren is a fan and advocate of design patterns, graphical Unified Modeling Language (UML) and fully-integrated model-driven software development as available for Enterprise Java and C++ and many other languages, but not currently available for PHP-driven Drupal - in part because of its lack of full Object-Orientation (as well as limitations of reverse engineering of untyped PHP). The OOE = Object Oriented Examples = One Of Each tutorial module helps address that.

When coding against OOE Classes one never has to touch a Drupal structured array or structured array key directly. OOE methods do all the work on structured arrays for you and pass them back to Drupal core via an object-oriented bridge to the flat function-based .module file with Drupal hooks that merely delegate to OOE classes via a IModuleMap ["bridge"] such as OoeBridge.

The OOE module promotes eternally preferrable Don't Repeat Yourself (DRY Principle) coding instead of Write Everything Twice (WET) (because "we enjoy typing") coding, which is simply rampant in Drupal, where strings representing structured array keys are sometimes repeated dozens of times within one module.

'OOE' can stand for Object Oriented Examples, and this site demonstrates via OOE = Object Oriented Examples = One Of Each an object-oriented bridge to Drupal7 core, including consistent graphical UML analysis diagrams of the OOE system. (A sibling site will later create an OO bridge to Drupal8, which unfortunately under the hood still codes directly against structured arrays, despite some progress towards more OOP).

It employs an extensive educational tutorial module called OOE = Object Oriented Examples = One Of Each to demonstrate (progressively) one of each of the possible features and capabilities of Drupal contributed modules, drawing heavily on existing examples, but translating them to truly object-oriented form.

[module] OOE = Object Oriented Examples = One Of Each

HOT TIP: this content is flagged as highly recommended !

The OOE module is the primary tutorial module for this demo site.

[video] Video: Demonstration of NetBeans IDE prompting on an OOE IMenuItem encapsulation of a Drupal menu item in object-oriented PHP {MediaFront}

Hover over the video and click the bottom-right button for full screen

[image] Screenshot: NetBeans IDE prompting on an OOE IMenuItem encapsulating a Drupal7 menu item

Click on the image to open it in an image viewer full size:

OOE graphical UML models

HOT TIP: this content is flagged as highly recommended !

This essential and unique subzone progressively includes information on the main Interfaces/Classes in the OOE = Object Oriented Examples = One Of Each object-oriented tutorial module, modelled here in graphical Unified Modeling Language (UML) using the Webel «!wrapper» @Components and «!analysis» @Interfaces recipe - a powerful UML analysis modelling strategy developed over many years by Dr Darren of Webel IT Australia, adapted here to parasitically analyse "already design(ed)" reverse-engineered PHP Interfaces/Classes.

QUICKSTART: use the search table of all UML elements for the OOE module with filters

[uml] Demo

Webel module:


UML element type:

OOE stereotypes:

extends [Generalization]: 
implements [InterfaceRealization]: 
UML Diagram
Click on the UML diagram to view it in a lightbox image viewer. You may then zoom in (or just open the image in a new web browser tab using the Download Original link to view large diagrams).

UML modelling domain:

Only those methods of the extended Components relevant to
the implementation by the Demo project are shown !

This is a minimal Demo project tutorial, just enough to show how an object-oriented OOE controlled project for Drupal has a primary menu item with a primary page controller and an "optional" block (which one can choose to enable/disable). This Demo project does not add any additional menu items to its menu items set (compare with DemoOfForms and DemoOfPageArguments ).

Because it does not add any public methods, there is no need to create a dedicated IDemo interface, IControlledProject serves fine from the point of view of the client OoeBridge.

To understand the main principles of the UML-friendly object-oriented Webel coding strategy for the OOE = Object Oriented Examples = One Of Each tutorial module please work through the UML diagrams and PHP code of this Demo project and compare it with the adapted CurrentPosts project (which unlike this Demo project does not use a page controller, and only extends AbstractProject).
Notes (policies)
Visit also

[uml] OoeBridge

REFACTOR: this software engineering content is flagged as under consideration for refactoring.

Webel module:

UML element type:

OOE stereotypes:

extends [Generalization]: 

The OoeBridge is the "go-between" that translates from the hooks of the Drupal core world in the ooe.module file and the truly object-oriented, UML-friendly, Webel style OOE PHP code.

Please do not be discouraged by the complexity of this large OOE module bridge overview diagram !

Most other UML diagrams in this OOE tutorial are broken down into smaller, easier-to-digest portions according to a tried and tested modelling recipe. By contrast, this diagram below deliberately provides an overview of the entire demonstration system.

When using OOE page controllers and form controllers with methods as validate/submit handlers, one does not have to pollute the .module file with so many custom callback functions. All you usually need are the main Drupal module hooks like hook_menu(), hook_block_info(), hook_block_view() etc., and these are handled in the bridge very efficiently with menu sets and block sets that collect the required information from, for example, OOE Project classes, and then pass it all back to Drupal as old-style Drupal structured arrays, or however Drupal core requires it.

[uml] Drupal\flagplus

Webel module:

UML element type:

OOE stereotypes:

Such package overview diagrams are useful for indicating the basic organisation of a module, but should not attempt to show too many Dependency, Usage, or Package/Element imports. Drill down into the dedicated "focus" class/implementation diagrams to see the detailed relationship of a focus element to its nearest neighbour related elements.

[pattern] Don't Repeat Yourself (DRY Principle)

HOT TIP: this content is flagged as highly recommended !

Drupal code (and note I don't blame PHP here), both core and contributed, breaks the DRY principle so often, so constantly, so annoyingly repetitively, that it actually makes me (otherwise used to nicely coded object-oriented Java or C++ with model-driven support through graphical UML) feel like this: jr-banghead.gif

This web site and the OOE = Object Oriented Examples = One Of Each module were in part created to discourage further repetition of .. well nearly everything that is repeated in Drupal code, like those strings used as keys of structured arrays that have no intelligence other than documented key conventions, instead of intelligent objects.

[antipattern] Write Everything Twice (WET) (because "we enjoy typing")

HOT TIP: this content is flagged as highly recommended !
Wikipedia quotes

In software engineering, don't repeat yourself (DRY) is a principle of software development aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures. The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." ..


DRY vs WET solution

Violations of DRY are typically referred to as WET solutions, which is commonly taken to stand for either "write everything twice", "we enjoy typing" or "waste everyone's time".

Source: Wikipedia: Don't repeat yourself, DRY vs WET solutions Version date: 2016-04-21

PLEASE READ TOP-TO-BOTTOM: This is an example of Writing Everything Twice (WET) code in typical Drupal-style, taken from the Current posts module example at Creating modules - a tutorial: Drupal 7.x:

Drupal CMS: how many web sites use Drupal, and how popular is it compared with other CMS systems ?

Webel IT Australia has made a major investment in Drupal for the better part of a decade, and runs dozens of Drupal6 and Drupal7 sites for a wide range of clients in industry, engineering, science and education as well as eCommerce sites and subscription sites for commercial clients, and some community web sites. It is pleasing to know that Drupal is growing in popularity, and in relative popularity compared with other CMS systems when measured amongst the world's most used web sites.

Drupal heresy

'It ain't necessarily so,
It ain't necessarily so,
The t'ings dat yo' li'ble,
To read in de [Drupal6/7] Bible,
It ain't necessarily so.'

Heresy: Doctrine rejected as false by religious authorities.

Logical fallacy: Appeal to popularity, Argumentum ad populum.

Dr Darren, Webel IT Australia, Drupal Heretic and disclosed fan of Design Patterns and graphical, model-driven software engineering with Unified Modeling Language (UML), Java, C++, and now graphical PHP for Drupal7.

Dr Darren says: 'Just because I (constructively) criticise some aspects of Drupal core and the module development API does not mean I don't appreciate Drupal and what one can do with it'

There are few CMS platforms that enable one to develop complex and powerful web sites as quickly as Drupal, and almost nothing can match the incredible Views query view/report system, and it deserves for many reasons to be a very popular world-leading CMS web site platform. If I were not a fan of Drupal, I would not bother to create a site like this designed to help improve its module development environment by introducing an object-oriented bridge for Drupal7.

TIP: NetBeans support for Drupal

These references are an absolute godsend for anybody developing contributed modules for Drupal in NetBeans IDE.

Please get rid of the verbose Drupal "Interface" suffix naming convention !

I consider the following Drupal OO recommendation completely unnecessary and not UML-friendly:
7. Interfaces should always have the suffix "Interface".

In the The Webel «!wrapper» @Components and «!analysis» @Interfaces recipe, interfaces are instead prefixed with a capital I followed by a CamelCase name like ICamelCase. This has many advantages:

- The 'I' acts like the Interface icon in UML and makes for much easier and more compact diagramming.

- It saves a massive amount of typing !

- It makes it much easier to prompt in IDEs and UML tools like MagicDraw UML on Interface elements, by just prompting on the 'I'. How on earth is one supposed to prompt on a suffix "Interface" ?

I will fight "tooth-and-nail" to get rid of the DrupalInterface suffix convention !

It has clearly been conceived by people who are likely not frequent graphical UML users, and are perhaps even relatively new to object-orientation. In modern IDE's like NetBeans or Eclipse and when using graphical UML support it is already perfectly clear whether something is an interface or not, one does not need to spell it out painfully with the word Interface. The UML-friendly OOE = Object Oriented Examples = One Of Each module will never, under any circumstances, adopt the verbose "Interface" suffix convention.

If you are likewise opposed to this convention, please join the debate at: Drupal.org: Object-oriented code (naming conventions): Please relax the verbose Drupal "Interface" suffix convention !

Visit also

DISCLAIMER: regarding promotion of the OMG-related graphical engineering technologies UML and SysML

DISCLAIMER: while Webel IT Australia is a long-term advocate for the graphical engineering technologies of the Object Management Group (OMG™), the OMG does not officially endorse the promotion of OMG technologies on this site. The term Webel UML recipe for PHP on this site refers to unendorsed adaptations of graphical engineering with Unified Modeling Language (UML™) suited especially for use with the MagicDraw UML tool, and adapted here for use with reverse-engineering of the PHP language (as used for Drupal CMS contributed modules).

Dr Darren of Webel IT Australia may well be more of a fan of the OMG's graphical engineering technologies than any other member of the OMG; he is also likely a more vocal critic of those software developers who refuse to "see the light" that only graphical engineering affords.

Why ? Because using graphical engineering to complement code-only engineering is like leaving Edwin Abbott's "Flatland" behind for multi-dimensional Spaceland (as so eloquently described by Carl Sagan in Cosmos) ! UML is to software engineering what Einstein's theories of relativity are to physics; developing deep insights requires new notations and new languages. As the wise quote attributed to Einstein says:

'"The significant problems we face can not be solved at the same level of thinking we were at when we created them."

Or as Dr Darren of Webel IT likes to say it: "Just using text/code-based software engineering is only using half your brain"