Language Selection

English French German Italian Portuguese Spanish

The Inverse Extension Design Pattern

Filed under
HowTos

In an inheritance hierarchy, permit each parent class's method to extend its child class's method so it can act as a decorator for its child class's behavior.

In object-oriented programming, it is common for a child class's method to extend the parent class's method. However, inverting this pattern is useful as well. Although most object-oriented programming languages support the former, I have never encountered one that supported the latter. Nonetheless, it is possible to implement this pattern without explicit support from the programming language, just as it was possible to implement inheritance in C before C++ was created.

A few interesting features of normal extension should be kept in mind. First, a child class can call its parent class's method anywhere within its own method. Hence, the child class is responsible for determining if the parent gets to go first, last or somewhere in the middle. Secondly, the child class gets to choose what to pass to the parent class's method and what to do with whatever, if anything, the parent class's method returns.

Full Article.

More in Tux Machines

Android Leftovers

ChromeOS 42.0.2311.87 (Official Build) (64-bit) – A brief look

ChromeOS is a crafty devil. If you are not paying attention you can miss the fact that you’ve received an update. Its a little like a dog near to a buffet table, turn away and it will have a cake off there and carry on as normal without you being any the wiser. I decided to pen a few thoughts on the latest build which has found its way through the interwebs and landed on my HP 14″. When I say land, the image I’d like to convey is not so much a smooth journey opening up a wealth of treats but more of a thump and an exercise in wasting my time. These are the things I’ve noticed within the first few hours of the update. There will be more. Read more

Debian 8.0 Installer RC3 "Jessie" Officially Released

Debian Installer, the official installation system for the Debian distribution since the Sarge release, developed the Debian Installer Team, has been upgraded to version 8.0 RC3 and is now available for download and testing. Read more

LibreOffice 5.0 to Arrive in July, Bug Hunt Organized

The Document Foundation is preparing the groundwork for the next major version of LibreOffice, 5.0, which should be available by the end of July, if everything goes according to plan. Read more